I’d like to create a unit test that resets the sys.path
variable to its original value.
Constraint: I cannot store a backup of sys.path in the location it’s being set.
Background
In a project there’s a need to fiddle with sys.path in order for imports to work from test code (because python does not support treating an import as a package without it being properly packaged and installed).
Project looks like this:
/
- domain_code
- tests
- __init__.py
sys.path.append(domain_code)
- test_xxx.py
- test_yyy.py
- test_zzz.py
in test_zzz.py, I’d like to reset the sys.path to it’s original value.