@@ -59,7 +59,7 @@ def test_getcfg_and_config(
59
59
),
60
60
encoding = "utf-8" ,
61
61
)
62
- _ , _ , cfg = locate_config ([sub ])
62
+ _ , _ , cfg = locate_config (Path . cwd (), [sub ])
63
63
assert cfg ["name" ] == "value"
64
64
config = pytester .parseconfigure (str (sub ))
65
65
assert config .inicfg ["name" ] == "value"
@@ -1436,16 +1436,16 @@ class pytest_something:
1436
1436
1437
1437
class TestRootdir :
1438
1438
def test_simple_noini (self , tmp_path : Path , monkeypatch : MonkeyPatch ) -> None :
1439
- assert get_common_ancestor ([tmp_path ]) == tmp_path
1439
+ assert get_common_ancestor (Path . cwd (), [tmp_path ]) == tmp_path
1440
1440
a = tmp_path / "a"
1441
1441
a .mkdir ()
1442
- assert get_common_ancestor ([a , tmp_path ]) == tmp_path
1443
- assert get_common_ancestor ([tmp_path , a ]) == tmp_path
1442
+ assert get_common_ancestor (Path . cwd (), [a , tmp_path ]) == tmp_path
1443
+ assert get_common_ancestor (Path . cwd (), [tmp_path , a ]) == tmp_path
1444
1444
monkeypatch .chdir (tmp_path )
1445
- assert get_common_ancestor ([]) == tmp_path
1445
+ assert get_common_ancestor (Path . cwd (), []) == tmp_path
1446
1446
no_path = tmp_path / "does-not-exist"
1447
- assert get_common_ancestor ([no_path ]) == tmp_path
1448
- assert get_common_ancestor ([no_path / "a" ]) == tmp_path
1447
+ assert get_common_ancestor (Path . cwd (), [no_path ]) == tmp_path
1448
+ assert get_common_ancestor (Path . cwd (), [no_path / "a" ]) == tmp_path
1449
1449
1450
1450
@pytest .mark .parametrize (
1451
1451
"name, contents" ,
@@ -1467,10 +1467,20 @@ def test_with_ini(self, tmp_path: Path, name: str, contents: str) -> None:
1467
1467
b = a / "b"
1468
1468
b .mkdir ()
1469
1469
for args in ([str (tmp_path )], [str (a )], [str (b )]):
1470
- rootpath , parsed_inipath , _ = determine_setup (None , args )
1470
+ rootpath , parsed_inipath , _ = determine_setup (
1471
+ inifile = None ,
1472
+ args = args ,
1473
+ rootdir_cmd_arg = None ,
1474
+ invocation_dir = Path .cwd (),
1475
+ )
1471
1476
assert rootpath == tmp_path
1472
1477
assert parsed_inipath == inipath
1473
- rootpath , parsed_inipath , ini_config = determine_setup (None , [str (b ), str (a )])
1478
+ rootpath , parsed_inipath , ini_config = determine_setup (
1479
+ inifile = None ,
1480
+ args = [str (b ), str (a )],
1481
+ rootdir_cmd_arg = None ,
1482
+ invocation_dir = Path .cwd (),
1483
+ )
1474
1484
assert rootpath == tmp_path
1475
1485
assert parsed_inipath == inipath
1476
1486
assert ini_config == {"x" : "10" }
@@ -1482,7 +1492,12 @@ def test_pytestini_overrides_empty_other(self, tmp_path: Path, name: str) -> Non
1482
1492
a = tmp_path / "a"
1483
1493
a .mkdir ()
1484
1494
(a / name ).touch ()
1485
- rootpath , parsed_inipath , _ = determine_setup (None , [str (a )])
1495
+ rootpath , parsed_inipath , _ = determine_setup (
1496
+ inifile = None ,
1497
+ args = [str (a )],
1498
+ rootdir_cmd_arg = None ,
1499
+ invocation_dir = Path .cwd (),
1500
+ )
1486
1501
assert rootpath == tmp_path
1487
1502
assert parsed_inipath == inipath
1488
1503
@@ -1491,14 +1506,24 @@ def test_setuppy_fallback(self, tmp_path: Path) -> None:
1491
1506
a .mkdir ()
1492
1507
(a / "setup.cfg" ).touch ()
1493
1508
(tmp_path / "setup.py" ).touch ()
1494
- rootpath , inipath , inicfg = determine_setup (None , [str (a )])
1509
+ rootpath , inipath , inicfg = determine_setup (
1510
+ inifile = None ,
1511
+ args = [str (a )],
1512
+ rootdir_cmd_arg = None ,
1513
+ invocation_dir = Path .cwd (),
1514
+ )
1495
1515
assert rootpath == tmp_path
1496
1516
assert inipath is None
1497
1517
assert inicfg == {}
1498
1518
1499
1519
def test_nothing (self , tmp_path : Path , monkeypatch : MonkeyPatch ) -> None :
1500
1520
monkeypatch .chdir (tmp_path )
1501
- rootpath , inipath , inicfg = determine_setup (None , [str (tmp_path )])
1521
+ rootpath , inipath , inicfg = determine_setup (
1522
+ inifile = None ,
1523
+ args = [str (tmp_path )],
1524
+ rootdir_cmd_arg = None ,
1525
+ invocation_dir = Path .cwd (),
1526
+ )
1502
1527
assert rootpath == tmp_path
1503
1528
assert inipath is None
1504
1529
assert inicfg == {}
@@ -1520,7 +1545,12 @@ def test_with_specific_inifile(
1520
1545
p = tmp_path / name
1521
1546
p .touch ()
1522
1547
p .write_text (contents , encoding = "utf-8" )
1523
- rootpath , inipath , ini_config = determine_setup (str (p ), [str (tmp_path )])
1548
+ rootpath , inipath , ini_config = determine_setup (
1549
+ inifile = str (p ),
1550
+ args = [str (tmp_path )],
1551
+ rootdir_cmd_arg = None ,
1552
+ invocation_dir = Path .cwd (),
1553
+ )
1524
1554
assert rootpath == tmp_path
1525
1555
assert inipath == p
1526
1556
assert ini_config == {"x" : "10" }
@@ -1534,14 +1564,24 @@ def test_explicit_config_file_sets_rootdir(
1534
1564
monkeypatch .chdir (tmp_path )
1535
1565
1536
1566
# No config file is explicitly given: rootdir is determined to be cwd.
1537
- rootpath , found_inipath , * _ = determine_setup (None , [str (tests_dir )])
1567
+ rootpath , found_inipath , * _ = determine_setup (
1568
+ inifile = None ,
1569
+ args = [str (tests_dir )],
1570
+ rootdir_cmd_arg = None ,
1571
+ invocation_dir = Path .cwd (),
1572
+ )
1538
1573
assert rootpath == tmp_path
1539
1574
assert found_inipath is None
1540
1575
1541
1576
# Config file is explicitly given: rootdir is determined to be inifile's directory.
1542
1577
inipath = tmp_path / "pytest.ini"
1543
1578
inipath .touch ()
1544
- rootpath , found_inipath , * _ = determine_setup (str (inipath ), [str (tests_dir )])
1579
+ rootpath , found_inipath , * _ = determine_setup (
1580
+ inifile = str (inipath ),
1581
+ args = [str (tests_dir )],
1582
+ rootdir_cmd_arg = None ,
1583
+ invocation_dir = Path .cwd (),
1584
+ )
1545
1585
assert rootpath == tmp_path
1546
1586
assert found_inipath == inipath
1547
1587
@@ -1553,7 +1593,12 @@ def test_with_arg_outside_cwd_without_inifile(
1553
1593
a .mkdir ()
1554
1594
b = tmp_path / "b"
1555
1595
b .mkdir ()
1556
- rootpath , inifile , _ = determine_setup (None , [str (a ), str (b )])
1596
+ rootpath , inifile , _ = determine_setup (
1597
+ inifile = None ,
1598
+ args = [str (a ), str (b )],
1599
+ rootdir_cmd_arg = None ,
1600
+ invocation_dir = Path .cwd (),
1601
+ )
1557
1602
assert rootpath == tmp_path
1558
1603
assert inifile is None
1559
1604
@@ -1564,7 +1609,12 @@ def test_with_arg_outside_cwd_with_inifile(self, tmp_path: Path) -> None:
1564
1609
b .mkdir ()
1565
1610
inipath = a / "pytest.ini"
1566
1611
inipath .touch ()
1567
- rootpath , parsed_inipath , _ = determine_setup (None , [str (a ), str (b )])
1612
+ rootpath , parsed_inipath , _ = determine_setup (
1613
+ inifile = None ,
1614
+ args = [str (a ), str (b )],
1615
+ rootdir_cmd_arg = None ,
1616
+ invocation_dir = Path .cwd (),
1617
+ )
1568
1618
assert rootpath == a
1569
1619
assert inipath == parsed_inipath
1570
1620
@@ -1573,7 +1623,12 @@ def test_with_non_dir_arg(
1573
1623
self , dirs : Sequence [str ], tmp_path : Path , monkeypatch : MonkeyPatch
1574
1624
) -> None :
1575
1625
monkeypatch .chdir (tmp_path )
1576
- rootpath , inipath , _ = determine_setup (None , dirs )
1626
+ rootpath , inipath , _ = determine_setup (
1627
+ inifile = None ,
1628
+ args = dirs ,
1629
+ rootdir_cmd_arg = None ,
1630
+ invocation_dir = Path .cwd (),
1631
+ )
1577
1632
assert rootpath == tmp_path
1578
1633
assert inipath is None
1579
1634
@@ -1584,7 +1639,12 @@ def test_with_existing_file_in_subdir(
1584
1639
a .mkdir ()
1585
1640
(a / "exists" ).touch ()
1586
1641
monkeypatch .chdir (tmp_path )
1587
- rootpath , inipath , _ = determine_setup (None , ["a/exist" ])
1642
+ rootpath , inipath , _ = determine_setup (
1643
+ inifile = None ,
1644
+ args = ["a/exist" ],
1645
+ rootdir_cmd_arg = None ,
1646
+ invocation_dir = Path .cwd (),
1647
+ )
1588
1648
assert rootpath == tmp_path
1589
1649
assert inipath is None
1590
1650
@@ -1598,7 +1658,12 @@ def test_with_config_also_in_parent_directory(
1598
1658
(tmp_path / "myproject" / "tests" ).mkdir ()
1599
1659
monkeypatch .chdir (tmp_path / "myproject" )
1600
1660
1601
- rootpath , inipath , _ = determine_setup (None , ["tests/" ])
1661
+ rootpath , inipath , _ = determine_setup (
1662
+ inifile = None ,
1663
+ args = ["tests/" ],
1664
+ rootdir_cmd_arg = None ,
1665
+ invocation_dir = Path .cwd (),
1666
+ )
1602
1667
1603
1668
assert rootpath == tmp_path / "myproject"
1604
1669
assert inipath == tmp_path / "myproject" / "setup.cfg"
0 commit comments