Fix monkeypatch.setenv with string and raising=False.

Fixes #746.
This commit is contained in:
Florian Bruhin
2015-05-19 22:59:49 +02:00
parent 3401049dea
commit ff8d787cd5
2 changed files with 10 additions and 4 deletions

View File

@@ -62,6 +62,11 @@ class TestSetattrWithImportPath:
pytest.raises(pytest.fail.Exception,
lambda: monkeypatch.setattr("os.path.qweqwe", None))
def test_unknown_attr_non_raising(self, monkeypatch):
# https://bitbucket.org/pytest-dev/pytest/issue/746/
monkeypatch.setattr('os.path.qweqwe', 42, raising=False)
assert os.path.qweqwe == 42
def test_delattr(self, monkeypatch):
monkeypatch.delattr("os.path.abspath")
assert not hasattr(os.path, "abspath")