File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ run though, it will pass.
7575If any difference is found between the database and the test fixture, then
7676``diff() `` will return the diff as outputed by GNU diff.
7777
78+ Instead of deleting the fixtures manually before running the tests to
79+ regenerate them, just run your tests with FIXTURE_REWRITE=1 environment
80+ variable. This will overwrite the fixtures and make the tests look like it
81+ passed.
82+
7883See tests and docstrings for crunchy details.
7984
8085Requirements
Original file line number Diff line number Diff line change 1818)
1919
2020
21+ REWRITE = os .getenv ('FIXTURE_REWRITE' )
22+
23+
2124class Fixture (object ):
2225 """
2326 Is able to print out diffs between database and a fixture.
@@ -130,10 +133,11 @@ def assertNoDiff(self, exclude=None): # noqa
130133
131134 If a diff was found it will raise :py:class:`~exceptions.DiffFound`.
132135 """
133- if not self .exists :
136+ if REWRITE or not self .exists :
134137 with open (self .path , 'w+' ) as f :
135138 self .dump (f )
136- raise FixtureCreated (self )
139+ if not REWRITE :
140+ raise FixtureCreated (self )
137141
138142 unexpected , missing , different = self .diff (exclude = exclude )
139143
You can’t perform that action at this time.
0 commit comments