mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Moved sys.path-extending decorator to django.test.utils and used throughout test suite.
Thanks Aymeric for the suggestion.
This commit is contained in:
@@ -526,3 +526,15 @@ class TransRealMixin(object):
|
||||
requires_tz_support = skipUnless(TZ_SUPPORT,
|
||||
"This test relies on the ability to run a program in an arbitrary "
|
||||
"time zone, but your operating system isn't able to do that.")
|
||||
|
||||
|
||||
|
||||
@contextmanager
|
||||
def extend_sys_path(*paths):
|
||||
"""Context manager to temporarily add paths to sys.path."""
|
||||
_orig_sys_path = sys.path[:]
|
||||
sys.path.extend(paths)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
sys.path = _orig_sys_path
|
||||
|
||||
Reference in New Issue
Block a user