1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Made testing of stdout and stderr more consistent.

Refs #23663.
This commit is contained in:
Loic Bistuer
2014-10-22 00:15:10 +07:00
parent 533532302a
commit 494ba051bb
6 changed files with 123 additions and 135 deletions

View File

@@ -10,10 +10,6 @@ class MultiDBChangepasswordManagementCommandTestCase(TestCase):
def setUp(self):
self.user = models.User.objects.db_manager('other').create_user(username='joe', password='qwerty')
self.stdout = StringIO()
def tearDown(self):
self.stdout.close()
def test_that_changepassword_command_with_database_option_uses_given_db(self):
"""
@@ -24,8 +20,9 @@ class MultiDBChangepasswordManagementCommandTestCase(TestCase):
command = changepassword.Command()
command._get_pass = lambda *args: 'not qwerty'
command.execute(username="joe", database='other', stdout=self.stdout)
command_output = self.stdout.getvalue().strip()
out = StringIO()
command.execute(username="joe", database='other', stdout=out)
command_output = out.getvalue().strip()
self.assertEqual(command_output, "Changing password for user 'joe'\nPassword changed successfully for user 'joe'")
self.assertTrue(models.User.objects.using('other').get(username="joe").check_password("not qwerty"))