summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_scripts/tests.py
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-05-23 18:54:02 +0000
committerRamiro Morales <cramm0@gmail.com>2011-05-23 18:54:02 +0000
commitc0303f5d8160d4a31bc46947e0a901d4eea2d201 (patch)
tree881b4dacb052ccddfce701879930b6a97d34b106 /tests/regressiontests/admin_scripts/tests.py
parente683beb6079122cd8ab90909ea8c4e7a6cfde36c (diff)
Workaround particularities of Python under Windows that interfere with expected outputs in `admin_scripts` regression tests.
Thye were causing most of them to fail in such platform. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_scripts/tests.py')
-rw-r--r--tests/regressiontests/admin_scripts/tests.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index 5fcc9fe4c0..11bd5c687a 100644
--- a/tests/regressiontests/admin_scripts/tests.py
+++ b/tests/regressiontests/admin_scripts/tests.py
@@ -157,7 +157,18 @@ class AdminScriptTestCase(unittest.TestCase):
def assertNoOutput(self, stream):
"Utility assertion: assert that the given stream is empty"
+ # HACK: Under Windows, ignore warnings of the form:
+ # 'warning: Not loading directory '...\tests\regressiontests\locale': missing __init__.py'
+ # It has been impossible to filter them out using other means like:
+ # * Using warning.filterwarnings() (for the Python interpreter running the
+ # tests) and/or
+ # * Using -Wignore:... (for the python interpreter spawned in self.run_test())
+ # Instead use a strategy copied from Mercurial's setup.py
+ if sys.platform == 'win32':
+ stream = [e for e in stream.splitlines()
+ if not e.startswith('warning: Not importing directory')]
self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
+
def assertOutput(self, stream, msg):
"Utility assertion: assert that the given message exists in the output"
self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
@@ -545,10 +556,11 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
"directory: startapp creates the correct directory"
test_dir = os.path.dirname(os.path.dirname(__file__))
args = ['startapp','settings_test']
+ app_path = os.path.join(test_dir, 'settings_test')
out, err = self.run_django_admin(args,'settings')
+ self.addCleanup(shutil.rmtree, app_path)
self.assertNoOutput(err)
- self.assertTrue(os.path.exists(os.path.join(test_dir, 'settings_test')))
- shutil.rmtree(os.path.join(test_dir, 'settings_test'))
+ self.assertTrue(os.path.exists(app_path))
def test_builtin_command(self):
"directory: django-admin builtin commands fail with an import error when no settings provided"