summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2023-11-21 17:13:08 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-11-28 06:19:38 +0100
commit6089230d3ec580f2f44e85f23962c14905fefcfd (patch)
treeeb243025bb58a778e16466fe96dac9dbc067bb95 /tests/utils_tests
parent0fcd72bc48eade21ce9202d7a71692f9b5a42bd2 (diff)
Refs #34986 -- Fixed mocking in utils_tests.test_http.HttpDateProcessingTests.test_parsing_rfc850.
Mocking in the `datetime` module can be tricky. In CPython the datetime C module is used, but PyPy uses a pure Python implementation. This caused issues with the prior approach to mocking `datetime.datetime`. See https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_http.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index 818c35e597..68df04696a 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -334,10 +334,9 @@ class HttpDateProcessingTests(unittest.TestCase):
)
@unittest.skipIf(platform.architecture()[0] == "32bit", "The Year 2038 problem.")
- @mock.patch("django.utils.http.datetime.datetime")
+ @mock.patch("django.utils.http.datetime")
def test_parsing_rfc850(self, mocked_datetime):
mocked_datetime.side_effect = datetime
- mocked_datetime.now = mock.Mock()
now_1 = datetime(2019, 11, 6, 8, 49, 37, tzinfo=timezone.utc)
now_2 = datetime(2020, 11, 6, 8, 49, 37, tzinfo=timezone.utc)
now_3 = datetime(2048, 11, 6, 8, 49, 37, tzinfo=timezone.utc)