Without this, test_git.py could fail because test_ftp had left its
GIT_DIR lying around, and other tests could fail because it changed
and didn't restore the working directory. Make sure to call tzset()
after any TZ changes.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
running the executable, are located in test/ext.
+Some aspects of the environment are automatically restored after each
+test via fixtures in conftest.py, including the state of the
+environment variables and the working directory; the latter is reset
+to the top of the source tree.
+
Submitting patches
==================
--- /dev/null
+
+from os.path import dirname, realpath
+from time import tzset
+import os
+import pytest
+import sys
+
+sys.path[:0] = ['lib']
+
+from bup import helpers
+from bup.compat import environ, fsencode
+
+
+_bup_src_top = realpath(dirname(fsencode(__file__)))
+
+@pytest.fixture(autouse=True)
+def ephemeral_env_changes():
+ orig_env = environ.copy()
+ yield None
+ for k, orig_v in orig_env.items():
+ v = environ.get(k)
+ if v is not orig_v:
+ environ[k] = orig_v
+ if k == b'TZ':
+ tzset()
+ for k in environ.keys():
+ if k not in orig_env:
+ del environ[k]
+ if k == b'TZ':
+ tzset()
+ os.chdir(_bup_src_top)