@@ -1372,7 +1372,7 @@ def test_2():
1372
1372
1373
1373
1374
1374
class TestGroupScope :
1375
- def test_by_module (self , testdir ):
1375
+ def test_by_module (self , pytester : pytest . Pytester ):
1376
1376
test_file = """
1377
1377
import pytest
1378
1378
class TestA:
@@ -1381,8 +1381,8 @@ class TestA:
1381
1381
def test(self, i):
1382
1382
pass
1383
1383
"""
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" )
1386
1386
test_a_workers_and_test_count = get_workers_and_test_count_by_prefix (
1387
1387
"test_a.py::TestA" , result .outlines
1388
1388
)
@@ -1403,8 +1403,8 @@ def test(self, i):
1403
1403
== test_b_workers_and_test_count .items ()
1404
1404
)
1405
1405
1406
- def test_by_class (self , testdir ):
1407
- testdir .makepyfile (
1406
+ def test_by_class (self , pytester : pytest . Pytester ):
1407
+ pytester .makepyfile (
1408
1408
test_a = """
1409
1409
import pytest
1410
1410
class TestA:
@@ -1419,7 +1419,7 @@ def test(self, i):
1419
1419
pass
1420
1420
"""
1421
1421
)
1422
- result = testdir .runpytest ("-n2" , "--dist=loadgroup" , "-v" )
1422
+ result = pytester .runpytest ("-n2" , "--dist=loadgroup" , "-v" )
1423
1423
test_a_workers_and_test_count = get_workers_and_test_count_by_prefix (
1424
1424
"test_a.py::TestA" , result .outlines
1425
1425
)
@@ -1440,7 +1440,7 @@ def test(self, i):
1440
1440
== test_b_workers_and_test_count .items ()
1441
1441
)
1442
1442
1443
- def test_module_single_start (self , testdir ):
1443
+ def test_module_single_start (self , pytester : pytest . Pytester ):
1444
1444
test_file1 = """
1445
1445
import pytest
1446
1446
@pytest.mark.xdist_group(name="xdist_group")
@@ -1455,15 +1455,15 @@ def test_1():
1455
1455
def test_2():
1456
1456
pass
1457
1457
"""
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" )
1460
1460
a = get_workers_and_test_count_by_prefix ("test_a.py::test" , result .outlines )
1461
1461
b = get_workers_and_test_count_by_prefix ("test_b.py::test" , result .outlines )
1462
1462
c = get_workers_and_test_count_by_prefix ("test_c.py::test_2" , result .outlines )
1463
1463
1464
1464
assert a .keys () == b .keys () and b .keys () == c .keys ()
1465
1465
1466
- def test_with_two_group_names (self , testdir ):
1466
+ def test_with_two_group_names (self , pytester : pytest . Pytester ):
1467
1467
test_file = """
1468
1468
import pytest
1469
1469
@pytest.mark.xdist_group(name="group1")
@@ -1473,8 +1473,8 @@ def test_1():
1473
1473
def test_2():
1474
1474
pass
1475
1475
"""
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" )
1478
1478
a_1 = get_workers_and_test_count_by_prefix ("test_a.py::test_1" , result .outlines )
1479
1479
a_2 = get_workers_and_test_count_by_prefix ("test_a.py::test_2" , result .outlines )
1480
1480
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:
1603
1603
assert xdist .get_xdist_worker_id (fake_request ) == "master"
1604
1604
1605
1605
1606
- def test_collection_crash (testdir ):
1607
- p1 = testdir .makepyfile (
1606
+ def test_collection_crash (pytester : pytest . Pytester ):
1607
+ p1 = pytester .makepyfile (
1608
1608
"""
1609
1609
assert 0
1610
1610
"""
1611
1611
)
1612
- result = testdir .runpytest (p1 , "-n1" )
1612
+ result = pytester .runpytest (p1 , "-n1" )
1613
1613
assert result .ret == 1
1614
1614
result .stdout .fnmatch_lines (
1615
1615
[
@@ -1622,19 +1622,19 @@ def test_collection_crash(testdir):
1622
1622
)
1623
1623
1624
1624
1625
- def test_dist_in_addopts (testdir ):
1625
+ def test_dist_in_addopts (pytester : pytest . Pytester ):
1626
1626
"""Users can set a default distribution in the configuration file (#789)."""
1627
- testdir .makepyfile (
1627
+ pytester .makepyfile (
1628
1628
"""
1629
1629
def test():
1630
1630
pass
1631
1631
"""
1632
1632
)
1633
- testdir .makeini (
1633
+ pytester .makeini (
1634
1634
"""
1635
1635
[pytest]
1636
1636
addopts = --dist loadscope
1637
1637
"""
1638
1638
)
1639
- result = testdir .runpytest ()
1639
+ result = pytester .runpytest ()
1640
1640
assert result .ret == 0
0 commit comments