Skip to content

Commit 470bc83

Browse files
authored
Merge pull request #1052 from bluetech/pytester
testing: replace `testdir` -> `pytester`
2 parents d96d87e + d63400e commit 470bc83

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

testing/acceptance_test.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ def test_2():
13721372

13731373

13741374
class TestGroupScope:
1375-
def test_by_module(self, testdir):
1375+
def test_by_module(self, pytester: pytest.Pytester):
13761376
test_file = """
13771377
import pytest
13781378
class TestA:
@@ -1381,8 +1381,8 @@ class TestA:
13811381
def test(self, i):
13821382
pass
13831383
"""
1384-
testdir.makepyfile(test_a=test_file, test_b=test_file)
1385-
result = testdir.runpytest("-n2", "--dist=loadgroup", "-v")
1384+
pytester.makepyfile(test_a=test_file, test_b=test_file)
1385+
result = pytester.runpytest("-n2", "--dist=loadgroup", "-v")
13861386
test_a_workers_and_test_count = get_workers_and_test_count_by_prefix(
13871387
"test_a.py::TestA", result.outlines
13881388
)
@@ -1403,8 +1403,8 @@ def test(self, i):
14031403
== test_b_workers_and_test_count.items()
14041404
)
14051405

1406-
def test_by_class(self, testdir):
1407-
testdir.makepyfile(
1406+
def test_by_class(self, pytester: pytest.Pytester):
1407+
pytester.makepyfile(
14081408
test_a="""
14091409
import pytest
14101410
class TestA:
@@ -1419,7 +1419,7 @@ def test(self, i):
14191419
pass
14201420
"""
14211421
)
1422-
result = testdir.runpytest("-n2", "--dist=loadgroup", "-v")
1422+
result = pytester.runpytest("-n2", "--dist=loadgroup", "-v")
14231423
test_a_workers_and_test_count = get_workers_and_test_count_by_prefix(
14241424
"test_a.py::TestA", result.outlines
14251425
)
@@ -1440,7 +1440,7 @@ def test(self, i):
14401440
== test_b_workers_and_test_count.items()
14411441
)
14421442

1443-
def test_module_single_start(self, testdir):
1443+
def test_module_single_start(self, pytester: pytest.Pytester):
14441444
test_file1 = """
14451445
import pytest
14461446
@pytest.mark.xdist_group(name="xdist_group")
@@ -1455,15 +1455,15 @@ def test_1():
14551455
def test_2():
14561456
pass
14571457
"""
1458-
testdir.makepyfile(test_a=test_file1, test_b=test_file1, test_c=test_file2)
1459-
result = testdir.runpytest("-n2", "--dist=loadgroup", "-v")
1458+
pytester.makepyfile(test_a=test_file1, test_b=test_file1, test_c=test_file2)
1459+
result = pytester.runpytest("-n2", "--dist=loadgroup", "-v")
14601460
a = get_workers_and_test_count_by_prefix("test_a.py::test", result.outlines)
14611461
b = get_workers_and_test_count_by_prefix("test_b.py::test", result.outlines)
14621462
c = get_workers_and_test_count_by_prefix("test_c.py::test_2", result.outlines)
14631463

14641464
assert a.keys() == b.keys() and b.keys() == c.keys()
14651465

1466-
def test_with_two_group_names(self, testdir):
1466+
def test_with_two_group_names(self, pytester: pytest.Pytester):
14671467
test_file = """
14681468
import pytest
14691469
@pytest.mark.xdist_group(name="group1")
@@ -1473,8 +1473,8 @@ def test_1():
14731473
def test_2():
14741474
pass
14751475
"""
1476-
testdir.makepyfile(test_a=test_file, test_b=test_file)
1477-
result = testdir.runpytest("-n2", "--dist=loadgroup", "-v")
1476+
pytester.makepyfile(test_a=test_file, test_b=test_file)
1477+
result = pytester.runpytest("-n2", "--dist=loadgroup", "-v")
14781478
a_1 = get_workers_and_test_count_by_prefix("test_a.py::test_1", result.outlines)
14791479
a_2 = get_workers_and_test_count_by_prefix("test_a.py::test_2", result.outlines)
14801480
b_1 = get_workers_and_test_count_by_prefix("test_b.py::test_1", result.outlines)
@@ -1603,13 +1603,13 @@ def test_get_xdist_worker_id(self, fake_request) -> None:
16031603
assert xdist.get_xdist_worker_id(fake_request) == "master"
16041604

16051605

1606-
def test_collection_crash(testdir):
1607-
p1 = testdir.makepyfile(
1606+
def test_collection_crash(pytester: pytest.Pytester):
1607+
p1 = pytester.makepyfile(
16081608
"""
16091609
assert 0
16101610
"""
16111611
)
1612-
result = testdir.runpytest(p1, "-n1")
1612+
result = pytester.runpytest(p1, "-n1")
16131613
assert result.ret == 1
16141614
result.stdout.fnmatch_lines(
16151615
[
@@ -1622,19 +1622,19 @@ def test_collection_crash(testdir):
16221622
)
16231623

16241624

1625-
def test_dist_in_addopts(testdir):
1625+
def test_dist_in_addopts(pytester: pytest.Pytester):
16261626
"""Users can set a default distribution in the configuration file (#789)."""
1627-
testdir.makepyfile(
1627+
pytester.makepyfile(
16281628
"""
16291629
def test():
16301630
pass
16311631
"""
16321632
)
1633-
testdir.makeini(
1633+
pytester.makeini(
16341634
"""
16351635
[pytest]
16361636
addopts = --dist loadscope
16371637
"""
16381638
)
1639-
result = testdir.runpytest()
1639+
result = pytester.runpytest()
16401640
assert result.ret == 0

0 commit comments

Comments
 (0)