diff options
author | Carl Meyer <carl@oddbird.net> | 2014-01-25 22:50:40 -0700 |
---|---|---|
committer | Carl Meyer <carl@oddbird.net> | 2014-01-25 22:50:40 -0700 |
commit | ca95f8e4359325567fa441eef8f18cb710850eeb (patch) | |
tree | 1f1ae7e470570a5c634d564a577740de3f2c77f1 /django/test/utils.py | |
parent | 8bc3780b67cc37dec04d622833dfa3a26c38fa84 (diff) | |
download | django-ca95f8e4359325567fa441eef8f18cb710850eeb.tar.gz |
Moved sys.path-extending decorator to django.test.utils and used throughout test suite.
Thanks Aymeric for the suggestion.
Diffstat (limited to 'django/test/utils.py')
-rw-r--r-- | django/test/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/django/test/utils.py b/django/test/utils.py index d205f5c9fb..7f47d29844 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -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 |