Skip to content

Commit 1eab7a9

Browse files
committed
Add minimal test replicating the issue. Use backports.unittest_mock==1.2 and tests pass. Ref pytest-dev/pytest#2419.
0 parents  commit 1eab7a9

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
name='testproj',
5+
version='1.0',
6+
)

test_issue.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
4+
@pytest.fixture(autouse=True)
5+
def try_backports_import_nowrite(monkeypatch):
6+
"""
7+
Simulate what happens in a setuptools sandbox when
8+
it attempts to prevent writing outside of the sandbox.
9+
"""
10+
def dont_mkdir(*args, **kwargs):
11+
raise RuntimeError("Don't make dirs")
12+
13+
monkeypatch.setattr('os.mkdir', dont_mkdir)
14+
15+
try:
16+
__import__('backports.does_not_exist')
17+
except ImportError:
18+
pass
19+
20+
def test_sunshine_and_roses():
21+
pass

tox.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[testenv]
2+
deps =
3+
pytest
4+
backports.unittest_mock==1.3
5+
6+
usedevelop = True
7+
commands = py.test {posargs}

0 commit comments

Comments
 (0)