1
0
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:
Carl Meyer
2014-01-25 22:50:40 -07:00
parent 8bc3780b67
commit ca95f8e435
6 changed files with 85 additions and 94 deletions

View File

@@ -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