mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #23083 -- Fixed runserver reloading when deleting a file.
Thanks Collin Anderson for the report and hirokiky for the fix.
This commit is contained in:
parent
08681d7757
commit
b8cb5ba708
2 changed files with 14 additions and 0 deletions
|
@ -1,9 +1,12 @@
|
|||
from importlib import import_module
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from django import conf
|
||||
from django.contrib import admin
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils.autoreload import gen_filenames
|
||||
from django.utils._os import upath
|
||||
|
||||
LOCALE_PATH = os.path.join(os.path.dirname(__file__), 'locale')
|
||||
|
||||
|
@ -82,3 +85,13 @@ class TestFilenameGenerator(TestCase):
|
|||
self.assertEqual(len(filenames2), 1)
|
||||
self.assertTrue(filenames2[0].endswith('fractions.py'))
|
||||
self.assertFalse(any(f.endswith('.pyc') for f in gen_filenames()))
|
||||
|
||||
def test_deleted_removed(self):
|
||||
_, filepath = tempfile.mkstemp(dir=os.path.dirname(upath(__file__)), suffix='.py')
|
||||
try:
|
||||
_, filename = os.path.split(filepath)
|
||||
import_module('.%s' % filename.rstrip('.py'), package='utils_tests')
|
||||
self.assertIn(filepath, gen_filenames())
|
||||
finally:
|
||||
os.remove(filepath)
|
||||
self.assertNotIn(filepath, gen_filenames())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue