Loading tests/auth_tests/test_tokens.py +2 −2 Original line number Diff line number Diff line import sys import unittest from datetime import date, timedelta Loading @@ -6,6 +5,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase from django.utils.six import PY3 class TokenGeneratorTest(TestCase): Loading Loading @@ -54,7 +54,7 @@ class TokenGeneratorTest(TestCase): p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1)) self.assertFalse(p2.check_token(user, tk1)) @unittest.skipIf(sys.version_info[:2] >= (3, 0), "Unnecessary test with Python 3") @unittest.skipIf(PY3, "Unnecessary test with Python 3") def test_date_length(self): """ Make sure we don't allow overly long dates, causing a potential DoS. Loading tests/migrations/test_commands.py +38 −51 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ import os from django.apps import apps from django.core.management import CommandError, call_command from django.db import DatabaseError, connection, models from django.db.migrations import questioner from django.test import ignore_warnings, mock, override_settings from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning Loading Loading @@ -535,8 +534,7 @@ class MakeMigrationsTests(MigrationTestBase): Makes sure that makemigrations enters and exits interactive mode properly. """ # Monkeypatch interactive questioner to auto reject old_input = questioner.input questioner.input = lambda _: "N" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: call_command("makemigrations", "migrations", merge=True, interactive=True, verbosity=0) Loading @@ -544,16 +542,13 @@ class MakeMigrationsTests(MigrationTestBase): self.assertFalse(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input def test_makemigrations_interactive_accept(self): """ Makes sure that makemigrations enters interactive mode and merges properly. """ # Monkeypatch interactive questioner to auto accept old_input = questioner.input questioner.input = lambda _: "y" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): out = six.StringIO() try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: Loading @@ -562,8 +557,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertTrue(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input self.assertIn("Created new merge migration", force_text(out.getvalue())) def test_makemigrations_non_interactive_not_null_addition(self): Loading Loading @@ -777,9 +770,8 @@ class MakeMigrationsTests(MigrationTestBase): behavior when --noinput is specified. """ # Monkeypatch interactive questioner to auto reject old_input = questioner.input questioner.input = lambda _: "N" out = six.StringIO() with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: call_command("makemigrations", "migrations", merge=True, stdout=out) Loading @@ -788,8 +780,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertFalse(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input self.assertNotIn("Created new merge migration", out.getvalue()) @override_settings( Loading Loading @@ -817,8 +807,7 @@ class MakeMigrationsTests(MigrationTestBase): unspecified app even if it has conflicting migrations. """ # Monkeypatch interactive questioner to auto accept old_input = questioner.input questioner.input = lambda _: "y" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): out = six.StringIO() try: with self.temporary_migration_module(app_label="migrated_app") as migration_dir: Loading @@ -828,8 +817,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertIn("No conflicts detected to merge.", out.getvalue()) except CommandError: self.fail("Makemigrations fails resolving conflicts in an unspecified app") finally: questioner.input = old_input def test_makemigrations_with_custom_name(self): """ Loading Loading
tests/auth_tests/test_tokens.py +2 −2 Original line number Diff line number Diff line import sys import unittest from datetime import date, timedelta Loading @@ -6,6 +5,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase from django.utils.six import PY3 class TokenGeneratorTest(TestCase): Loading Loading @@ -54,7 +54,7 @@ class TokenGeneratorTest(TestCase): p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1)) self.assertFalse(p2.check_token(user, tk1)) @unittest.skipIf(sys.version_info[:2] >= (3, 0), "Unnecessary test with Python 3") @unittest.skipIf(PY3, "Unnecessary test with Python 3") def test_date_length(self): """ Make sure we don't allow overly long dates, causing a potential DoS. Loading
tests/migrations/test_commands.py +38 −51 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ import os from django.apps import apps from django.core.management import CommandError, call_command from django.db import DatabaseError, connection, models from django.db.migrations import questioner from django.test import ignore_warnings, mock, override_settings from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning Loading Loading @@ -535,8 +534,7 @@ class MakeMigrationsTests(MigrationTestBase): Makes sure that makemigrations enters and exits interactive mode properly. """ # Monkeypatch interactive questioner to auto reject old_input = questioner.input questioner.input = lambda _: "N" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: call_command("makemigrations", "migrations", merge=True, interactive=True, verbosity=0) Loading @@ -544,16 +542,13 @@ class MakeMigrationsTests(MigrationTestBase): self.assertFalse(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input def test_makemigrations_interactive_accept(self): """ Makes sure that makemigrations enters interactive mode and merges properly. """ # Monkeypatch interactive questioner to auto accept old_input = questioner.input questioner.input = lambda _: "y" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): out = six.StringIO() try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: Loading @@ -562,8 +557,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertTrue(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input self.assertIn("Created new merge migration", force_text(out.getvalue())) def test_makemigrations_non_interactive_not_null_addition(self): Loading Loading @@ -777,9 +770,8 @@ class MakeMigrationsTests(MigrationTestBase): behavior when --noinput is specified. """ # Monkeypatch interactive questioner to auto reject old_input = questioner.input questioner.input = lambda _: "N" out = six.StringIO() with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): try: with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: call_command("makemigrations", "migrations", merge=True, stdout=out) Loading @@ -788,8 +780,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertFalse(os.path.exists(merge_file)) except CommandError: self.fail("Makemigrations failed while running interactive questioner") finally: questioner.input = old_input self.assertNotIn("Created new merge migration", out.getvalue()) @override_settings( Loading Loading @@ -817,8 +807,7 @@ class MakeMigrationsTests(MigrationTestBase): unspecified app even if it has conflicting migrations. """ # Monkeypatch interactive questioner to auto accept old_input = questioner.input questioner.input = lambda _: "y" with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): out = six.StringIO() try: with self.temporary_migration_module(app_label="migrated_app") as migration_dir: Loading @@ -828,8 +817,6 @@ class MakeMigrationsTests(MigrationTestBase): self.assertIn("No conflicts detected to merge.", out.getvalue()) except CommandError: self.fail("Makemigrations fails resolving conflicts in an unspecified app") finally: questioner.input = old_input def test_makemigrations_with_custom_name(self): """ Loading