Skip to content

Commit

Permalink
DRY the test which I WETted
Browse files Browse the repository at this point in the history
  • Loading branch information
hashbrowncipher authored and gaborbernat committed Oct 11, 2018
1 parent 1bf846d commit 534a5e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 74 deletions.
4 changes: 4 additions & 0 deletions docs/changelog/1051.bugfix.rst
@@ -0,0 +1,4 @@
Do the same transformation to egg_info dirs that pkg_resources does. This makes
it possible for hyphenated names to use the develop-inst-noop optimization (cf.
#910), which previously only worked with non-hyphenated egg names - by
:user:`hashbrowncipher`.
85 changes: 11 additions & 74 deletions tests/unit/test_z_cmdline.py
Expand Up @@ -528,10 +528,12 @@ def test_usedevelop_mixed(initproj, cmd):
assert "sdist-make" in result.out


@pytest.mark.parametrize("skipsdist", [False, True])
@pytest.mark.parametrize("src_root", [".", "src"])
def test_test_usedevelop(cmd, initproj, src_root, monkeypatch):
def test_test_usedevelop(cmd, initproj, src_root, skipsdist, monkeypatch):
name = "example123-spameggs"
base = initproj(
"example123-0.5",
(name, "0.5"),
src_root=src_root,
filedefs={
"tests": {
Expand All @@ -546,77 +548,12 @@ def test_hello(pytestconfig):
changedir=tests
commands=
pytest --basetemp={envtmpdir} --junitxml=junit-{envname}.xml []
deps=pytest
""",
},
)
result = cmd("-v")
assert not result.ret
assert re.match(
r".*generated\W+xml\W+file.*junit-python\.xml" r".*\W+1\W+passed.*", result.out, re.DOTALL
)
assert "sdist-make" not in result.out
result = cmd("-epython")
assert not result.ret
assert "develop-inst-noop" in result.out
assert re.match(
r".*\W+1\W+passed.*" r"summary.*" r"python:\W+commands\W+succeeded.*",
result.out,
re.DOTALL,
)

# see that things work with a different CWD
monkeypatch.chdir(base.dirname)
result = cmd("-c", "example123/tox.ini")
assert not result.ret
assert "develop-inst-noop" in result.out
assert re.match(
r".*\W+1\W+passed.*" r"summary.*" r"python:\W+commands\W+succeeded.*",
result.out,
re.DOTALL,
)
monkeypatch.chdir(base)

# see that tests can also fail and retcode is correct
testfile = py.path.local("tests").join("test_hello.py")
assert testfile.check()
testfile.write("def test_fail(): assert 0")
result = cmd()
assert result.ret, "{}\n{}".format(result.err, result.out)
assert "develop-inst-noop" in result.out
assert re.match(
r".*\W+1\W+failed.*" r"summary.*" r"python:\W+commands\W+failed.*", result.out, re.DOTALL
)

# test develop is called if setup.py changes
setup_py = py.path.local("setup.py")
setup_py.write(setup_py.read() + " ")
result = cmd()
assert result.ret, "{}\n{}".format(result.err, result.out)
assert "develop-inst-nodeps" in result.out


@pytest.mark.parametrize("src_root", [".", "src"])
def test_test_usedevelop_skipsdist(cmd, initproj, src_root, monkeypatch):
base = initproj(
"example123-spameggs-0.5",
src_root=src_root,
filedefs={
"tests": {
"test_hello.py": """
def test_hello(pytestconfig):
pass
"""
},
"tox.ini": """
[testenv]
usedevelop=True
skipsdist=True
changedir=tests
commands=
pytest --basetemp={envtmpdir} --junitxml=junit-{envname}.xml []
deps=pytest
""",
deps=pytest"""
+ """
skipsdist={}
""".format(
skipsdist
),
},
)
result = cmd("-v")
Expand All @@ -636,7 +573,7 @@ def test_hello(pytestconfig):

# see that things work with a different CWD
monkeypatch.chdir(base.dirname)
result = cmd("-c", "example123-spameggs/tox.ini")
result = cmd("-c", "{}/tox.ini".format(name))
assert not result.ret
assert "develop-inst-noop" in result.out
assert re.match(
Expand Down

0 comments on commit 534a5e6

Please sign in to comment.