From 4a80395a63b982847ff2e9a7faba908f2e11c08e Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 18 Oct 2015 11:49:15 +0000 Subject: [PATCH] Removed support for perma_fixtures, using the blobal test fixtures instead. - Legacy-Id: 10228 --- ietf/nomcom/tests.py | 6 ----- ietf/settings.py | 2 +- ietf/utils/test_utils.py | 47 +--------------------------------------- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py index 69772bf70..42b0a30a3 100644 --- a/ietf/nomcom/tests.py +++ b/ietf/nomcom/tests.py @@ -41,8 +41,6 @@ def get_cert_files(): class NomcomViewsTest(TestCase): """Tests to create a new nomcom""" - # See ietf.utils.test_utils.TestCase for the use of perma_fixtures vs. fixtures - perma_fixtures = ['nomcom_templates'] def check_url_status(self, url, status): response = self.client.get(url) @@ -745,8 +743,6 @@ class NomcomViewsTest(TestCase): class NomineePositionStateSaveTest(TestCase): """Tests for the NomineePosition save override method""" - # See ietf.utils.test_utils.TestCase for the use of perma_fixtures vs. fixtures - perma_fixtures = ['nomcom_templates'] def setUp(self): self.nomcom_public_keys_dir = os.path.abspath("tmp-nomcom-public-keys-dir") @@ -786,7 +782,6 @@ class NomineePositionStateSaveTest(TestCase): class FeedbackTest(TestCase): - perma_fixtures = ['nomcom_templates'] def setUp(self): self.nomcom_public_keys_dir = os.path.abspath("tmp-nomcom-public-keys-dir") @@ -823,7 +818,6 @@ class FeedbackTest(TestCase): self.assertEqual(check_comments(feedback.comments, comments, self.privatekey_file), True) class ReminderTest(TestCase): - perma_fixtures = ['nomcom_templates'] def setUp(self): self.nomcom_public_keys_dir = os.path.abspath("tmp-nomcom-public-keys-dir") diff --git a/ietf/settings.py b/ietf/settings.py index 8075f7a45..13e9c3814 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -322,7 +322,7 @@ RFCDIFF_BASE_URL = "https://www.ietf.org/rfcdiff" TEST_RUNNER = 'ietf.utils.test_runner.IetfTestRunner' # Fixtures which will be loaded before testing starts -GLOBAL_TEST_FIXTURES = [ 'names','ietf.utils.test_data.make_immutable_base_data' ] +GLOBAL_TEST_FIXTURES = [ 'names','ietf.utils.test_data.make_immutable_base_data','nomcom_templates' ] TEST_DIFF_FAILURE_DIR = "/tmp/test/failure/" diff --git a/ietf/utils/test_utils.py b/ietf/utils/test_utils.py index 53ce091e3..c500cc05f 100644 --- a/ietf/utils/test_utils.py +++ b/ietf/utils/test_utils.py @@ -269,58 +269,13 @@ class ReverseLazyTest(django.test.TestCase): response = self.client.get('/ipr/update/') self.assertRedirects(response, "/ipr/", status_code=301) -loaded_fixtures = [] - class TestCase(django.test.TestCase): """ - Does basically the same as django.test.TestCase, but if the test database has - support for transactions, it loads perma_fixtures before the transaction which - surrounds every test. This causes the perma_fixtures to stay in the database - after the transaction which surrounds each test is rolled back, which lets us - load each preload_fixture only once. However, it requires that all the - perma_fixtures are consistent with each other and with all regular fixtures - across all applications. You could view the perma_fixtures as on_the_fly - initial_data for tests. - - Regular fixtures are re-loaded for each TestCase, as usual. - - We don't flush the database, as that triggers a re-load of initial_data. + Does basically the same as django.test.TestCase, but adds asserts for html5 validation. """ parser = html5lib.HTMLParser(strict=True) - def _fixture_setup(self): - global loaded_fixtures - - if not connections_support_transactions(): - if hasattr(self, 'perma_fixtures'): - if not hasattr(self, 'fixtures'): - self.fixtures = self.perma_fixtures - else: - self.fixtures += self.perma_fixtures - return super(TestCase, self)._fixture_setup() - - # If the test case has a multi_db=True flag, setup all databases. - # Otherwise, just use default. - if getattr(self, 'multi_db', False): - databases = connections - else: - databases = [DEFAULT_DB_ALIAS] - - for db in databases: - if hasattr(self, 'perma_fixtures'): - fixtures = [ fixture for fixture in self.perma_fixtures if not fixture in loaded_fixtures ] - if fixtures: - call_command('loaddata', *fixtures, **{ - 'verbosity': 0, - 'commit': False, - 'database': db - }) - loaded_fixtures += fixtures - - super(TestCase, self)._fixture_setup() - - def assertValidHTML(self, data): try: self.parser.parse(data)