summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-03 18:02:59 -0500
committerTim Graham <timograham@gmail.com>2015-02-03 18:30:46 -0500
commitc0cc8f69e7abfa8578729031f97ae4b96c5cdafe (patch)
tree7d8530b7e682abda046cbd7015816d1cb5c19b24 /tests
parent65e005f8cd9c656e558e53e6c8b890cd0fcc9e74 (diff)
downloaddjango-c0cc8f69e7abfa8578729031f97ae4b96c5cdafe.tar.gz
Refactored tests that rely on an ImportError for Python 3.5 compatibility
A change in Python test discovery [1] causes the old packages that raised an error to be discovered; now we use a common directory that's ignored during discovery. Refs #23763. [1] http://bugs.python.org/issue7559
Diffstat (limited to 'tests')
-rw-r--r--tests/apps/failing_app/__init__.py1
-rw-r--r--tests/apps/tests.py2
-rw-r--r--tests/import_error_package/__init__.py3
-rw-r--r--tests/migrations/faulty_migrations/import_error/__init__.py1
-rw-r--r--tests/migrations/test_loader.py2
-rwxr-xr-xtests/runtests.py1
6 files changed, 6 insertions, 4 deletions
diff --git a/tests/apps/failing_app/__init__.py b/tests/apps/failing_app/__init__.py
deleted file mode 100644
index 4ec7f18d40..0000000000
--- a/tests/apps/failing_app/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-raise ImportError("Oops")
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index f6bef17e42..b7652ed355 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -172,7 +172,7 @@ class AppsTests(TestCase):
App discovery should preserve stack traces. Regression test for #22920.
"""
with six.assertRaisesRegex(self, ImportError, "Oops"):
- with self.settings(INSTALLED_APPS=['apps.failing_app']):
+ with self.settings(INSTALLED_APPS=['import_error_package']):
pass
def test_models_py(self):
diff --git a/tests/import_error_package/__init__.py b/tests/import_error_package/__init__.py
new file mode 100644
index 0000000000..c872aec5a7
--- /dev/null
+++ b/tests/import_error_package/__init__.py
@@ -0,0 +1,3 @@
+# A package that raises an ImportError that can be shared among test apps and
+# excluded from test discovery.
+raise ImportError("Oops")
diff --git a/tests/migrations/faulty_migrations/import_error/__init__.py b/tests/migrations/faulty_migrations/import_error/__init__.py
deleted file mode 100644
index a07bc4fa6d..0000000000
--- a/tests/migrations/faulty_migrations/import_error/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-import fake_python_module # NOQA
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index 4416a86bc9..8df7b7aa9b 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -159,7 +159,7 @@ class LoaderTests(TestCase):
migration_loader.get_migration_by_prefix("migrations", "blarg")
def test_load_import_error(self):
- with override_settings(MIGRATION_MODULES={"migrations": "migrations.faulty_migrations.import_error"}):
+ with override_settings(MIGRATION_MODULES={"migrations": "import_error_package"}):
with self.assertRaises(ImportError):
MigrationLoader(connection)
diff --git a/tests/runtests.py b/tests/runtests.py
index e232da9c63..e3e118c908 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -35,6 +35,7 @@ os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
SUBDIRS_TO_SKIP = [
'data',
+ 'import_error_package',
'test_discovery_sample',
'test_discovery_sample2',
'test_runner_deprecation_app',