mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager.
This commit is contained in:
committed by
Tim Graham
parent
fee42fd99e
commit
6478e07a62
@@ -98,8 +98,7 @@ class MigrationTestBase(TransactionTestCase):
|
||||
|
||||
Returns the filesystem path to the temporary migrations module.
|
||||
"""
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
target_dir = tempfile.mkdtemp(dir=temp_dir)
|
||||
with open(os.path.join(target_dir, '__init__.py'), 'w'):
|
||||
pass
|
||||
@@ -119,6 +118,3 @@ class MigrationTestBase(TransactionTestCase):
|
||||
new_module = os.path.basename(target_dir) + '.migrations'
|
||||
with self.settings(MIGRATION_MODULES={app_label: new_module}):
|
||||
yield target_migrations_dir
|
||||
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
Reference in New Issue
Block a user