summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorTom Forbes <tom@tomforb.es>2019-01-19 00:16:33 +0000
committerTim Graham <timograham@gmail.com>2019-01-28 14:42:46 -0500
commit728358c5cf96898a00eea2f81a2e305c0754f0c3 (patch)
treebe219334bc3f0256692e31a2d8306b16bc6d1016 /tests/utils_tests
parent2ca200a7c3dcb0ddb9fc8eeea1a0a0a2803c3dd5 (diff)
[2.2.x] Fixed #25624 -- Fixed autoreload crash with jinja2.ModuleLoader.
Backport of 1e92407f83ed35be35f876777935b983ab9587be from master.
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_autoreload.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index 6aa272dd9a..de05e2d5f5 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -6,6 +6,7 @@ import sys
import tempfile
import threading
import time
+import weakref
import zipfile
from importlib import import_module
from pathlib import Path
@@ -116,6 +117,13 @@ class TestIterModulesAndFiles(SimpleTestCase):
self.import_and_cleanup('test_compiled')
self.assertFileFound(compiled_file)
+ def test_weakref_in_sys_module(self):
+ """iter_all_python_module_file() ignores weakref modules."""
+ time_proxy = weakref.proxy(time)
+ sys.modules['time_proxy'] = time_proxy
+ self.addCleanup(lambda: sys.modules.pop('time_proxy', None))
+ list(autoreload.iter_all_python_module_files()) # No crash.
+
class TestCommonRoots(SimpleTestCase):
def test_common_roots(self):