Skip to content

Commit

Permalink
SchemaTests: delete migration files in tearDownClass method
Browse files Browse the repository at this point in the history
Avoid leaving migration files if the method test_migration fails
or tests are interrupted.

Related to #103
  • Loading branch information
nemesifier committed Apr 23, 2015
1 parent 8bf5a1b commit f37817c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/django_hstore_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,16 @@ def test_str(self):

class SchemaTests(TestCase):
if DJANGO_VERSION[:2] >= (1, 6):
@classmethod
def tearDownClass(cls):
# delete migration files
migration_path = '{0}/{1}'.format(os.path.dirname(__file__), 'migrations')
import shutil
try:
shutil.rmtree(migration_path)
except OSError:
pass

def _login_as_admin(self):
# create admin user
admin = User.objects.create(username='admin', password='tester', is_staff=True, is_superuser=True, is_active=True)
Expand Down Expand Up @@ -1556,9 +1566,6 @@ class Migration(migrations.Migration):
# stop capturing print statements
sys.stdout = sys.__stdout__
self.assertIn('Applying django_hstore_tests.0002_issue_103... OK', output.getvalue())
# delete migration files
import shutil
shutil.rmtree(path)
else:
def test_improperly_configured(self):
with self.assertRaises(ImproperlyConfigured):
Expand Down

0 comments on commit f37817c

Please sign in to comment.