diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/tests.py | 2 | ||||
| -rw-r--r-- | tests/constraints/tests.py | 7 | ||||
| -rw-r--r-- | tests/expressions/tests.py | 2 | ||||
| -rw-r--r-- | tests/filtered_relation/tests.py | 5 | ||||
| -rw-r--r-- | tests/messages_tests/tests.py | 3 | ||||
| -rw-r--r-- | tests/model_indexes/tests.py | 3 | ||||
| -rw-r--r-- | tests/postgres_tests/test_constraints.py | 2 | ||||
| -rw-r--r-- | tests/prefetch_related/tests.py | 3 | ||||
| -rw-r--r-- | tests/template_tests/test_context.py | 3 | ||||
| -rw-r--r-- | tests/validators/tests.py | 3 |
10 files changed, 32 insertions, 1 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 89f6048c96..5eada343e1 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -1,5 +1,6 @@ import threading from datetime import datetime, timedelta +from unittest import mock from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections, models @@ -354,6 +355,7 @@ class ModelTest(TestCase): self.assertNotEqual(object(), Article(id=1)) a = Article() self.assertEqual(a, a) + self.assertEqual(a, mock.ANY) self.assertNotEqual(Article(), a) def test_hash(self): diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py index 3b28c99e7f..8e2eb11e2a 100644 --- a/tests/constraints/tests.py +++ b/tests/constraints/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.core.exceptions import ValidationError from django.db import IntegrityError, connection, models from django.db.models.constraints import BaseConstraint @@ -39,6 +41,7 @@ class CheckConstraintTests(TestCase): models.CheckConstraint(check=check1, name='price'), models.CheckConstraint(check=check1, name='price'), ) + self.assertEqual(models.CheckConstraint(check=check1, name='price'), mock.ANY) self.assertNotEqual( models.CheckConstraint(check=check1, name='price'), models.CheckConstraint(check=check1, name='price2'), @@ -102,6 +105,10 @@ class UniqueConstraintTests(TestCase): models.UniqueConstraint(fields=['foo', 'bar'], name='unique'), models.UniqueConstraint(fields=['foo', 'bar'], name='unique'), ) + self.assertEqual( + models.UniqueConstraint(fields=['foo', 'bar'], name='unique'), + mock.ANY, + ) self.assertNotEqual( models.UniqueConstraint(fields=['foo', 'bar'], name='unique'), models.UniqueConstraint(fields=['foo', 'bar'], name='unique2'), diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index f50c634014..094b738792 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -3,6 +3,7 @@ import pickle import unittest import uuid from copy import deepcopy +from unittest import mock from django.core.exceptions import FieldError from django.db import DatabaseError, connection, models @@ -965,6 +966,7 @@ class SimpleExpressionTests(SimpleTestCase): Expression(models.IntegerField()), Expression(output_field=models.IntegerField()) ) + self.assertEqual(Expression(models.IntegerField()), mock.ANY) self.assertNotEqual( Expression(models.IntegerField()), Expression(models.CharField()) diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 52fe64dfa5..48154413a5 100644 --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.db import connection, transaction from django.db.models import Case, Count, F, FilteredRelation, Q, When from django.test import TestCase @@ -323,6 +325,9 @@ class FilteredRelationTests(TestCase): [self.book1] ) + def test_eq(self): + self.assertEqual(FilteredRelation('book', condition=Q(book__title='b')), mock.ANY) + class FilteredRelationAggregationTests(TestCase): diff --git a/tests/messages_tests/tests.py b/tests/messages_tests/tests.py index 1464783b33..eea07c9c41 100644 --- a/tests/messages_tests/tests.py +++ b/tests/messages_tests/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.contrib.messages import constants from django.contrib.messages.storage.base import Message from django.test import SimpleTestCase @@ -9,6 +11,7 @@ class MessageTests(SimpleTestCase): msg_2 = Message(constants.INFO, 'Test message 2') msg_3 = Message(constants.WARNING, 'Test message 1') self.assertEqual(msg_1, msg_1) + self.assertEqual(msg_1, mock.ANY) self.assertNotEqual(msg_1, msg_2) self.assertNotEqual(msg_1, msg_3) self.assertNotEqual(msg_2, msg_3) diff --git a/tests/model_indexes/tests.py b/tests/model_indexes/tests.py index ade27e1a4b..6a31109031 100644 --- a/tests/model_indexes/tests.py +++ b/tests/model_indexes/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.conf import settings from django.db import connection, models from django.db.models.query_utils import Q @@ -28,6 +30,7 @@ class SimpleIndexesTests(SimpleTestCase): same_index.model = Book another_index.model = Book self.assertEqual(index, same_index) + self.assertEqual(index, mock.ANY) self.assertNotEqual(index, another_index) def test_index_fields_type(self): diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py index d8665f59f6..b22821294a 100644 --- a/tests/postgres_tests/test_constraints.py +++ b/tests/postgres_tests/test_constraints.py @@ -1,4 +1,5 @@ import datetime +from unittest import mock from django.db import connection, transaction from django.db.models import F, Func, Q @@ -175,6 +176,7 @@ class ExclusionConstraintTests(PostgreSQLTestCase): condition=Q(cancelled=False), ) self.assertEqual(constraint_1, constraint_1) + self.assertEqual(constraint_1, mock.ANY) self.assertNotEqual(constraint_1, constraint_2) self.assertNotEqual(constraint_1, constraint_3) self.assertNotEqual(constraint_2, constraint_3) diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py index 9ae939dcdf..930ba9fbc8 100644 --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db import connection @@ -243,6 +245,7 @@ class PrefetchRelatedTests(TestDataMixin, TestCase): prefetch_1 = Prefetch('authors', queryset=Author.objects.all()) prefetch_2 = Prefetch('books', queryset=Book.objects.all()) self.assertEqual(prefetch_1, prefetch_1) + self.assertEqual(prefetch_1, mock.ANY) self.assertNotEqual(prefetch_1, prefetch_2) def test_forward_m2m_to_attr_conflict(self): diff --git a/tests/template_tests/test_context.py b/tests/template_tests/test_context.py index 8c6fc98b42..1150a14639 100644 --- a/tests/template_tests/test_context.py +++ b/tests/template_tests/test_context.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.http import HttpRequest from django.template import ( Context, Engine, RequestContext, Template, Variable, VariableDoesNotExist, @@ -18,6 +20,7 @@ class ContextTests(SimpleTestCase): self.assertEqual(c.pop(), {"a": 2}) self.assertEqual(c["a"], 1) self.assertEqual(c.get("foo", 42), 42) + self.assertEqual(c, mock.ANY) def test_push_context_manager(self): c = Context({"a": 1}) diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 36d0b2a520..295c6c899f 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -3,7 +3,7 @@ import re import types from datetime import datetime, timedelta from decimal import Decimal -from unittest import TestCase +from unittest import TestCase, mock from django.core.exceptions import ValidationError from django.core.files.base import ContentFile @@ -424,6 +424,7 @@ class TestValidatorEquality(TestCase): MaxValueValidator(44), MaxValueValidator(44), ) + self.assertEqual(MaxValueValidator(44), mock.ANY) self.assertNotEqual( MaxValueValidator(44), MinValueValidator(44), |
