summaryrefslogtreecommitdiff
path: root/tests/regressiontests/multiple_database/tests.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-06-05 05:32:05 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-06-05 05:32:05 +0000
commit45e5fb1ee224e99b612072b1a50f562856d540b6 (patch)
treef51bfdbfde4c568ad96ef931dc489b0801fae70b /tests/regressiontests/multiple_database/tests.py
parent5da6aeba17060fb986ae209a3f463383454b2970 (diff)
Migrated multiple_database tests to use new stdout argument on management commands, rather than monkeypatching stdout.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13320 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/multiple_database/tests.py')
-rw-r--r--tests/regressiontests/multiple_database/tests.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index 7bde8bf037..bae9544465 100644
--- a/tests/regressiontests/multiple_database/tests.py
+++ b/tests/regressiontests/multiple_database/tests.py
@@ -1491,19 +1491,10 @@ class AuthTestCase(TestCase):
self.old_routers = router.routers
router.routers = [AuthRouter()]
- # Redirect stdout to a buffer so we can test
- # the output of a management command
- self.old_stdout = sys.stdout
- self.stdout = StringIO()
- sys.stdout = self.stdout
-
def tearDown(self):
# Restore the 'other' database as an independent database
router.routers = self.old_routers
- # Restore stdout
- sys.stdout = self.old_stdout
-
def test_auth_manager(self):
"The methods on the auth manager obey database hints"
# Create one user using default allocation policy
@@ -1539,14 +1530,16 @@ class AuthTestCase(TestCase):
# Check that dumping the default database doesn't try to include auth
# because allow_syncdb prohibits auth on default
- self.stdout.flush()
- management.call_command('dumpdata', 'auth', format='json', database='default')
- self.assertEquals(self.stdout.getvalue(), '[]\n')
+ new_io = StringIO()
+ management.call_command('dumpdata', 'auth', format='json', database='default', stdout=new_io)
+ command_output = new_io.getvalue().strip()
+ self.assertEqual(command_output, '[]')
# Check that dumping the other database does include auth
- self.stdout.flush()
- management.call_command('dumpdata', 'auth', format='json', database='other')
- self.assertTrue('alice@example.com' in self.stdout.getvalue())
+ new_io = StringIO()
+ management.call_command('dumpdata', 'auth', format='json', database='other', stdout=new_io)
+ command_output = new_io.getvalue().strip()
+ self.assertTrue('"email": "alice@example.com",' in command_output)
class UserProfileTestCase(TestCase):
def setUp(self):