Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #3015

Merged
merged 11 commits into from Dec 12, 2017
330 changes: 161 additions & 169 deletions _pytest/pytester.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions changelog/3015.trivial
@@ -0,0 +1 @@
Code cleanup.
18 changes: 9 additions & 9 deletions testing/acceptance_test.py
Expand Up @@ -215,8 +215,8 @@ def test_chdir(self, testdir):
assert not result.ret

def test_issue109_sibling_conftests_not_loaded(self, testdir):
sub1 = testdir.tmpdir.mkdir("sub1")
sub2 = testdir.tmpdir.mkdir("sub2")
sub1 = testdir.mkdir("sub1")
sub2 = testdir.mkdir("sub2")
sub1.join("conftest.py").write("assert 0")
result = testdir.runpytest(sub2)
assert result.ret == EXIT_NOTESTSCOLLECTED
Expand Down Expand Up @@ -603,11 +603,11 @@ def test_cmdline_python_namespace_package(self, testdir, monkeypatch):
# The structure of the test directory is now:
# .
# ├── hello
# │   └── ns_pkg
# │   ├── __init__.py
# │   └── hello
# │   ├── __init__.py
# │   └── test_hello.py
# │ └── ns_pkg
# │ ├── __init__.py
# │ └── hello
# │ ├── __init__.py
# │ └── test_hello.py
# └── world
# └── ns_pkg
# ├── __init__.py
Expand All @@ -624,10 +624,9 @@ def join_pythonpath(*dirs):
for p in search_path:
monkeypatch.syspath_prepend(p)

os.chdir('world')
# mixed module and filenames:
os.chdir('world')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code<> commend swap looks unintended

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I thought it seemed correct - there are two pytest runs here and for each we set up a suitable cwd folder

easy enough to revert if you dislike it, I'm just curious as to what the intended meaning here was then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, in full context it looks correct after all - before this change the lines where directly matching the code in question, but now its indeed marking the test sections instead

result = testdir.runpytest("--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world")
testdir.chdir()
assert result.ret == 0
result.stdout.fnmatch_lines([
"*test_hello.py::test_hello*PASSED*",
Expand All @@ -638,6 +637,7 @@ def join_pythonpath(*dirs):
])

# specify tests within a module
testdir.chdir()
result = testdir.runpytest("--pyargs", "-v", "ns_pkg.world.test_world::test_other")
assert result.ret == 0
result.stdout.fnmatch_lines([
Expand Down
2 changes: 1 addition & 1 deletion testing/test_conftest.py
Expand Up @@ -84,7 +84,7 @@ def test_conftest_in_nonpkg_with_init(tmpdir):

def test_doubledash_considered(testdir):
conf = testdir.mkdir("--option")
conf.join("conftest.py").ensure()
conf.ensure("conftest.py")
conftest = PytestPluginManager()
conftest_setinitial(conftest, [conf.basename, conf.basename])
values = conftest._getconftestmodules(conf)
Expand Down
2 changes: 1 addition & 1 deletion testing/test_pdb.py
Expand Up @@ -338,7 +338,7 @@ def test_foo(a):
self.flush(child)

def test_pdb_collection_failure_is_shown(self, testdir):
p1 = testdir.makepyfile("""xxx """)
p1 = testdir.makepyfile("xxx")
result = testdir.runpytest_subprocess("--pdb", p1)
result.stdout.fnmatch_lines([
"*NameError*xxx*",
Expand Down
2 changes: 1 addition & 1 deletion testing/test_pytester.py
Expand Up @@ -141,7 +141,7 @@ def test_inline_run_clean_modules(testdir):
assert result2.ret == EXIT_TESTSFAILED


def test_assert_outcomes_after_pytest_erro(testdir):
def test_assert_outcomes_after_pytest_error(testdir):
testdir.makepyfile("def test_foo(): assert True")

result = testdir.runpytest('--unexpected-argument')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -138,7 +138,7 @@ commands =
basepython = python
usedevelop = True
skipsdist = True
# ensure the given pyargs cant mean anytrhing else
# ensure the given pyargs can't mean anything else
changedir = doc/
deps =
PyYAML
Expand Down