diff options
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 |