Skip to content

Commit 5c6d773

Browse files
authored
Merge pull request #3015 from jurko-gospodnetic/code-cleanup
Code cleanup
2 parents 771b5c8 + 3b85e0c commit 5c6d773

File tree

7 files changed

+176
-187
lines changed

7 files changed

+176
-187
lines changed

_pytest/pytester.py

Lines changed: 161 additions & 169 deletions
Large diffs are not rendered by default.

changelog/3015.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Code cleanup.

testing/acceptance_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def test_chdir(self, testdir):
215215
assert not result.ret
216216

217217
def test_issue109_sibling_conftests_not_loaded(self, testdir):
218-
sub1 = testdir.tmpdir.mkdir("sub1")
219-
sub2 = testdir.tmpdir.mkdir("sub2")
218+
sub1 = testdir.mkdir("sub1")
219+
sub2 = testdir.mkdir("sub2")
220220
sub1.join("conftest.py").write("assert 0")
221221
result = testdir.runpytest(sub2)
222222
assert result.ret == EXIT_NOTESTSCOLLECTED
@@ -603,11 +603,11 @@ def test_cmdline_python_namespace_package(self, testdir, monkeypatch):
603603
# The structure of the test directory is now:
604604
# .
605605
# ├── hello
606-
# │   └── ns_pkg
607-
# │   ├── __init__.py
608-
# │   └── hello
609-
# │   ├── __init__.py
610-
# │   └── test_hello.py
606+
# │ └── ns_pkg
607+
# │ ├── __init__.py
608+
# │ └── hello
609+
# │ ├── __init__.py
610+
# │ └── test_hello.py
611611
# └── world
612612
# └── ns_pkg
613613
# ├── __init__.py
@@ -624,10 +624,9 @@ def join_pythonpath(*dirs):
624624
for p in search_path:
625625
monkeypatch.syspath_prepend(p)
626626

627-
os.chdir('world')
628627
# mixed module and filenames:
628+
os.chdir('world')
629629
result = testdir.runpytest("--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world")
630-
testdir.chdir()
631630
assert result.ret == 0
632631
result.stdout.fnmatch_lines([
633632
"*test_hello.py::test_hello*PASSED*",
@@ -638,6 +637,7 @@ def join_pythonpath(*dirs):
638637
])
639638

640639
# specify tests within a module
640+
testdir.chdir()
641641
result = testdir.runpytest("--pyargs", "-v", "ns_pkg.world.test_world::test_other")
642642
assert result.ret == 0
643643
result.stdout.fnmatch_lines([

testing/test_conftest.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_conftest_in_nonpkg_with_init(tmpdir):
8484

8585
def test_doubledash_considered(testdir):
8686
conf = testdir.mkdir("--option")
87-
conf.join("conftest.py").ensure()
87+
conf.ensure("conftest.py")
8888
conftest = PytestPluginManager()
8989
conftest_setinitial(conftest, [conf.basename, conf.basename])
9090
values = conftest._getconftestmodules(conf)
@@ -270,11 +270,7 @@ def pytest_addoption(parser):
270270
parser.addoption("--hello-world", action="store_true")
271271
"""))
272272
p = sub.join("test_hello.py")
273-
p.write(py.std.textwrap.dedent("""
274-
import pytest
275-
def test_hello(found):
276-
assert found == 1
277-
"""))
273+
p.write("def test_hello(): pass")
278274
result = testdir.runpytest(str(p) + "::test_hello", "-h")
279275
result.stdout.fnmatch_lines("""
280276
*--hello-world*

testing/test_pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def test_foo(a):
338338
self.flush(child)
339339

340340
def test_pdb_collection_failure_is_shown(self, testdir):
341-
p1 = testdir.makepyfile("""xxx """)
341+
p1 = testdir.makepyfile("xxx")
342342
result = testdir.runpytest_subprocess("--pdb", p1)
343343
result.stdout.fnmatch_lines([
344344
"*NameError*xxx*",

testing/test_pytester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def test_inline_run_clean_modules(testdir):
141141
assert result2.ret == EXIT_TESTSFAILED
142142

143143

144-
def test_assert_outcomes_after_pytest_erro(testdir):
144+
def test_assert_outcomes_after_pytest_error(testdir):
145145
testdir.makepyfile("def test_foo(): assert True")
146146

147147
result = testdir.runpytest('--unexpected-argument')

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ commands =
138138
basepython = python
139139
usedevelop = True
140140
skipsdist = True
141-
# ensure the given pyargs cant mean anytrhing else
141+
# ensure the given pyargs can't mean anything else
142142
changedir = doc/
143143
deps =
144144
PyYAML

0 commit comments

Comments
 (0)