Loading tests/modeltests/invalid_models/tests.py +2 −2 Original line number Diff line number Diff line import copy import sys from io import BytesIO from django.core.management.validation import get_validation_errors from django.db.models.loading import cache, load_app from django.utils import unittest from django.utils.six import StringIO class InvalidModelTestCase(unittest.TestCase): Loading @@ -16,7 +16,7 @@ class InvalidModelTestCase(unittest.TestCase): # coloring attached (makes matching the results easier). We restore # sys.stderr afterwards. self.old_stdout = sys.stdout self.stdout = BytesIO() self.stdout = StringIO() sys.stdout = self.stdout # This test adds dummy applications to the app cache. These Loading tests/regressiontests/fixtures_regress/tests.py +5 −5 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ from __future__ import absolute_import, unicode_literals import os import re from io import BytesIO from django.core import management from django.core.management.base import CommandError Loading @@ -14,6 +13,7 @@ from django.db.models import signals from django.test import (TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature) from django.test.utils import override_settings from django.utils.six import StringIO from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget, Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3, Loading Loading @@ -276,7 +276,7 @@ class TestFixtures(TestCase): ) animal.save() stdout = BytesIO() stdout = StringIO() management.call_command( 'dumpdata', 'fixtures_regress.animal', Loading Loading @@ -305,7 +305,7 @@ class TestFixtures(TestCase): """ Regression for #11428 - Proxy models aren't included when you dumpdata """ stdout = BytesIO() stdout = StringIO() # Create an instance of the concrete class widget = Widget.objects.create(name='grommet') management.call_command( Loading Loading @@ -380,7 +380,7 @@ class TestFixtures(TestCase): ) def test_loaddata_not_existant_fixture_file(self): stdout_output = BytesIO() stdout_output = StringIO() management.call_command( 'loaddata', 'this_fixture_doesnt_exist', Loading Loading @@ -465,7 +465,7 @@ class NaturalKeyFixtureTests(TestCase): commit=False ) stdout = BytesIO() stdout = StringIO() management.call_command( 'dumpdata', 'fixtures_regress.book', Loading tests/regressiontests/m2m_through_regress/tests.py +4 −5 Original line number Diff line number Diff line from __future__ import absolute_import from io import BytesIO from django.core import management from django.contrib.auth.models import User from django.test import TestCase from django.utils.six import StringIO from .models import (Person, Group, Membership, UserMembership, Car, Driver, CarDriver) Loading Loading @@ -70,11 +69,11 @@ class M2MThroughTestCase(TestCase): pks = {"p_pk": p.pk, "g_pk": g.pk, "m_pk": m.pk} out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertEqual(out.getvalue().strip(), """[{"pk": %(m_pk)s, "model": "m2m_through_regress.membership", "fields": {"person": %(p_pk)s, "price": 100, "group": %(g_pk)s}}, {"pk": %(p_pk)s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk": %(g_pk)s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]""" % pks) out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="xml", indent=2, stdout=out) self.assertEqual(out.getvalue().strip(), """ Loading Loading @@ -142,6 +141,6 @@ class ThroughLoadDataTestCase(TestCase): def test_sequence_creation(self): "Check that sequences on an m2m_through are created for the through model, not a phantom auto-generated m2m table. Refs #11107" out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertEqual(out.getvalue().strip(), """[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}]""") tests/regressiontests/staticfiles_tests/tests.py +2 −3 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import posixpath import shutil import sys import tempfile from io import BytesIO from django.template import loader, Context from django.conf import settings Loading Loading @@ -194,7 +193,7 @@ class TestFindStatic(CollectionTestCase, TestDefaults): Test ``findstatic`` management command. """ def _get_file(self, filepath): out = BytesIO() out = six.StringIO() call_command('findstatic', filepath, all=False, verbosity=0, stdout=out) out.seek(0) lines = [l.strip() for l in out.readlines()] Loading @@ -206,7 +205,7 @@ class TestFindStatic(CollectionTestCase, TestDefaults): """ Test that findstatic returns all candidate files if run without --first. """ out = BytesIO() out = six.StringIO() call_command('findstatic', 'test/file.txt', verbosity=0, stdout=out) out.seek(0) lines = [l.strip() for l in out.readlines()] Loading Loading
tests/modeltests/invalid_models/tests.py +2 −2 Original line number Diff line number Diff line import copy import sys from io import BytesIO from django.core.management.validation import get_validation_errors from django.db.models.loading import cache, load_app from django.utils import unittest from django.utils.six import StringIO class InvalidModelTestCase(unittest.TestCase): Loading @@ -16,7 +16,7 @@ class InvalidModelTestCase(unittest.TestCase): # coloring attached (makes matching the results easier). We restore # sys.stderr afterwards. self.old_stdout = sys.stdout self.stdout = BytesIO() self.stdout = StringIO() sys.stdout = self.stdout # This test adds dummy applications to the app cache. These Loading
tests/regressiontests/fixtures_regress/tests.py +5 −5 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ from __future__ import absolute_import, unicode_literals import os import re from io import BytesIO from django.core import management from django.core.management.base import CommandError Loading @@ -14,6 +13,7 @@ from django.db.models import signals from django.test import (TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature) from django.test.utils import override_settings from django.utils.six import StringIO from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget, Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3, Loading Loading @@ -276,7 +276,7 @@ class TestFixtures(TestCase): ) animal.save() stdout = BytesIO() stdout = StringIO() management.call_command( 'dumpdata', 'fixtures_regress.animal', Loading Loading @@ -305,7 +305,7 @@ class TestFixtures(TestCase): """ Regression for #11428 - Proxy models aren't included when you dumpdata """ stdout = BytesIO() stdout = StringIO() # Create an instance of the concrete class widget = Widget.objects.create(name='grommet') management.call_command( Loading Loading @@ -380,7 +380,7 @@ class TestFixtures(TestCase): ) def test_loaddata_not_existant_fixture_file(self): stdout_output = BytesIO() stdout_output = StringIO() management.call_command( 'loaddata', 'this_fixture_doesnt_exist', Loading Loading @@ -465,7 +465,7 @@ class NaturalKeyFixtureTests(TestCase): commit=False ) stdout = BytesIO() stdout = StringIO() management.call_command( 'dumpdata', 'fixtures_regress.book', Loading
tests/regressiontests/m2m_through_regress/tests.py +4 −5 Original line number Diff line number Diff line from __future__ import absolute_import from io import BytesIO from django.core import management from django.contrib.auth.models import User from django.test import TestCase from django.utils.six import StringIO from .models import (Person, Group, Membership, UserMembership, Car, Driver, CarDriver) Loading Loading @@ -70,11 +69,11 @@ class M2MThroughTestCase(TestCase): pks = {"p_pk": p.pk, "g_pk": g.pk, "m_pk": m.pk} out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertEqual(out.getvalue().strip(), """[{"pk": %(m_pk)s, "model": "m2m_through_regress.membership", "fields": {"person": %(p_pk)s, "price": 100, "group": %(g_pk)s}}, {"pk": %(p_pk)s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk": %(g_pk)s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]""" % pks) out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="xml", indent=2, stdout=out) self.assertEqual(out.getvalue().strip(), """ Loading Loading @@ -142,6 +141,6 @@ class ThroughLoadDataTestCase(TestCase): def test_sequence_creation(self): "Check that sequences on an m2m_through are created for the through model, not a phantom auto-generated m2m table. Refs #11107" out = BytesIO() out = StringIO() management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) self.assertEqual(out.getvalue().strip(), """[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}]""")
tests/regressiontests/staticfiles_tests/tests.py +2 −3 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import posixpath import shutil import sys import tempfile from io import BytesIO from django.template import loader, Context from django.conf import settings Loading Loading @@ -194,7 +193,7 @@ class TestFindStatic(CollectionTestCase, TestDefaults): Test ``findstatic`` management command. """ def _get_file(self, filepath): out = BytesIO() out = six.StringIO() call_command('findstatic', filepath, all=False, verbosity=0, stdout=out) out.seek(0) lines = [l.strip() for l in out.readlines()] Loading @@ -206,7 +205,7 @@ class TestFindStatic(CollectionTestCase, TestDefaults): """ Test that findstatic returns all candidate files if run without --first. """ out = BytesIO() out = six.StringIO() call_command('findstatic', 'test/file.txt', verbosity=0, stdout=out) out.seek(0) lines = [l.strip() for l in out.readlines()] Loading