Skip to content

Commit

Permalink
Workaround particularities of Python under Windows that interfere wit…
Browse files Browse the repository at this point in the history
…h 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
  • Loading branch information
ramiro committed May 23, 2011
1 parent e683beb commit c0303f5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/regressiontests/admin_scripts/tests.py
Expand Up @@ -157,7 +157,18 @@ def run_manage(self, args, settings_file=None):


def assertNoOutput(self, stream): def assertNoOutput(self, stream):
"Utility assertion: assert that the given stream is empty" "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) self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)

def assertOutput(self, stream, msg): def assertOutput(self, stream, msg):
"Utility assertion: assert that the given message exists in the output" "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)) self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
Expand Down Expand Up @@ -545,10 +556,11 @@ def test_setup_environ(self):
"directory: startapp creates the correct directory" "directory: startapp creates the correct directory"
test_dir = os.path.dirname(os.path.dirname(__file__)) test_dir = os.path.dirname(os.path.dirname(__file__))
args = ['startapp','settings_test'] args = ['startapp','settings_test']
app_path = os.path.join(test_dir, 'settings_test')
out, err = self.run_django_admin(args,'settings') out, err = self.run_django_admin(args,'settings')
self.addCleanup(shutil.rmtree, app_path)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertTrue(os.path.exists(os.path.join(test_dir, 'settings_test'))) self.assertTrue(os.path.exists(app_path))
shutil.rmtree(os.path.join(test_dir, 'settings_test'))


def test_builtin_command(self): def test_builtin_command(self):
"directory: django-admin builtin commands fail with an import error when no settings provided" "directory: django-admin builtin commands fail with an import error when no settings provided"
Expand Down

0 comments on commit c0303f5

Please sign in to comment.