Merge pull request #4941 from blueyed/testdir-home
pytester: testdir: set $HOME to tmpdir
This commit is contained in:
commit
a624b84097
|
@ -0,0 +1,3 @@
|
||||||
|
``pytester``'s ``Testdir`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory.
|
||||||
|
|
||||||
|
This ensures to not load configuration files from the real user's home directory.
|
|
@ -469,6 +469,8 @@ class Testdir(object):
|
||||||
os.environ["PYTEST_DEBUG_TEMPROOT"] = str(self.test_tmproot)
|
os.environ["PYTEST_DEBUG_TEMPROOT"] = str(self.test_tmproot)
|
||||||
os.environ.pop("TOX_ENV_DIR", None) # Ensure that it is not used for caching.
|
os.environ.pop("TOX_ENV_DIR", None) # Ensure that it is not used for caching.
|
||||||
os.environ.pop("PYTEST_ADDOPTS", None) # Do not use outer options.
|
os.environ.pop("PYTEST_ADDOPTS", None) # Do not use outer options.
|
||||||
|
os.environ["HOME"] = str(self.tmpdir) # Do not load user config.
|
||||||
|
os.environ["USERPROFILE"] = os.environ["HOME"]
|
||||||
self.plugins = []
|
self.plugins = []
|
||||||
self._cwd_snapshot = CwdSnapshot()
|
self._cwd_snapshot = CwdSnapshot()
|
||||||
self._sys_path_snapshot = SysPathsSnapshot()
|
self._sys_path_snapshot = SysPathsSnapshot()
|
||||||
|
|
|
@ -816,16 +816,12 @@ def test_invalid_xml_escape():
|
||||||
assert chr(i) == bin_xml_escape(unichr(i)).uniobj
|
assert chr(i) == bin_xml_escape(unichr(i)).uniobj
|
||||||
|
|
||||||
|
|
||||||
def test_logxml_path_expansion(tmpdir, monkeypatch):
|
def test_logxml_path_expansion(tmpdir):
|
||||||
home_tilde = py.path.local(os.path.expanduser("~")).join("test.xml")
|
home_tilde = py.path.local(os.path.expanduser("~")).join("test.xml")
|
||||||
|
|
||||||
xml_tilde = LogXML("~%stest.xml" % tmpdir.sep, None)
|
xml_tilde = LogXML("~%stest.xml" % tmpdir.sep, None)
|
||||||
assert xml_tilde.logfile == home_tilde
|
assert xml_tilde.logfile == home_tilde
|
||||||
|
|
||||||
# this is here for when $HOME is not set correct
|
|
||||||
monkeypatch.setenv("HOME", str(tmpdir))
|
|
||||||
home_var = os.path.normpath(os.path.expandvars("$HOME/test.xml"))
|
home_var = os.path.normpath(os.path.expandvars("$HOME/test.xml"))
|
||||||
|
|
||||||
xml_var = LogXML("$HOME%stest.xml" % tmpdir.sep, None)
|
xml_var = LogXML("$HOME%stest.xml" % tmpdir.sep, None)
|
||||||
assert xml_var.logfile == home_var
|
assert xml_var.logfile == home_var
|
||||||
|
|
||||||
|
|
|
@ -470,9 +470,6 @@ class TestPDB(object):
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
# Prevent ~/.pdbrc etc to output anything.
|
|
||||||
monkeypatch.setenv("HOME", str(testdir))
|
|
||||||
|
|
||||||
child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
|
child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
|
||||||
child.expect("Pdb")
|
child.expect("Pdb")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue