@@ -1367,10 +1367,12 @@ def test_executor_should_be_initialized_with_correct_workers(
1367
1367
],
1368
1368
)
1369
1369
@pytest .mark .parametrize ("editable" , [False , True ])
1370
+ @pytest .mark .parametrize ("source_type" , ["directory" , "git" , "git subdirectory" ])
1370
1371
def test_build_backend_errors_are_reported_correctly_if_caused_by_subprocess (
1371
1372
failing_method : str ,
1372
1373
exception : Exception ,
1373
1374
editable : bool ,
1375
+ source_type : str ,
1374
1376
mocker : MockerFixture ,
1375
1377
config : Config ,
1376
1378
pool : RepositoryPool ,
@@ -1386,38 +1388,67 @@ def test_build_backend_errors_are_reported_correctly_if_caused_by_subprocess(
1386
1388
1387
1389
package_name = "simple-project"
1388
1390
package_version = "1.2.3"
1389
- directory_package = Package (
1391
+ source_reference : str | None = None
1392
+ source_sub_directory : str | None = None
1393
+ if source_type == "directory" :
1394
+ source_url = fixture_dir ("simple_project" ).resolve ().as_posix ()
1395
+ source_resolved_reference = None
1396
+ pip_url = path_to_url (source_url )
1397
+ pip_editable_requirement = source_url
1398
+ elif source_type == "git" :
1399
+ source_url = "https://github.com/demo/demo.git"
1400
+ source_reference = "v2.0"
1401
+ source_resolved_reference = "12345678"
1402
+ pip_url = f"git+{ source_url } @{ source_reference } "
1403
+ pip_editable_requirement = f"{ pip_url } #egg={ package_name } "
1404
+ elif source_type == "git subdirectory" :
1405
+ source_type = "git"
1406
+ source_sub_directory = "one"
1407
+ source_url = "https://github.com/demo/subdirectories.git"
1408
+ source_reference = "v2.0"
1409
+ source_resolved_reference = "12345678"
1410
+ pip_base_url = f"git+{ source_url } @{ source_reference } "
1411
+ pip_url = f"{ pip_base_url } #subdirectory={ source_sub_directory } "
1412
+ pip_editable_requirement = (
1413
+ f"{ pip_base_url } #egg={ package_name } &subdirectory={ source_sub_directory } "
1414
+ )
1415
+ else :
1416
+ raise ValueError (f"Unknown source type: { source_type } " )
1417
+ package = Package (
1390
1418
package_name ,
1391
1419
package_version ,
1392
- source_type = "directory" ,
1393
- source_url = fixture_dir ("simple_project" ).resolve ().as_posix (),
1420
+ source_type = source_type ,
1421
+ source_url = source_url ,
1422
+ source_reference = source_reference ,
1423
+ source_resolved_reference = source_resolved_reference ,
1424
+ source_subdirectory = source_sub_directory ,
1394
1425
develop = editable ,
1395
1426
)
1396
1427
# must not be included in the error message
1397
- directory_package .python_versions = ">=3.7"
1428
+ package .python_versions = ">=3.7"
1398
1429
1399
- return_code = executor .execute ([Install (directory_package )])
1430
+ return_code = executor .execute ([Install (package )])
1400
1431
1401
1432
assert return_code == 1
1402
1433
1403
- package_url = directory_package .source_url
1404
-
1405
- assert directory_package .source_url is not None
1434
+ assert package .source_url is not None
1406
1435
if editable :
1407
1436
pip_command = "pip wheel --no-cache-dir --use-pep517 --editable"
1408
- requirement = directory_package .source_url
1409
- assert Path (requirement ).exists ()
1437
+ requirement = pip_editable_requirement
1438
+ if source_type == "directory" :
1439
+ assert Path (requirement ).exists ()
1410
1440
else :
1411
1441
pip_command = "pip wheel --no-cache-dir --use-pep517"
1412
- requirement = f"{ package_name } @ { path_to_url ( directory_package . source_url ) } "
1442
+ requirement = f"{ package_name } @ { pip_url } "
1413
1443
1414
- expected_source_string = f"{ package_name } ({ package_version } { package_url } )"
1444
+ version_details = package .source_resolved_reference or package .source_url
1445
+ expected_source_string = f"{ package_name } ({ package_version } { version_details } )"
1415
1446
expected_pip_command = f'{ pip_command } "{ requirement } "'
1416
1447
1417
1448
expected_output = f"""
1418
1449
Package operations: 1 install, 0 updates, 0 removals
1419
1450
1420
- - Installing { package_name } ( { package_version } { package_url } )
1451
+ - Installing { expected_source_string }
1421
1452
1422
1453
PEP517 build of a dependency failed
1423
1454
@@ -1433,7 +1464,8 @@ def test_build_backend_errors_are_reported_correctly_if_caused_by_subprocess(
1433
1464
)
1434
1465
1435
1466
expected_output += f"""
1436
- Note: This error originates from the build backend, and is likely not a problem with poetry but one of the following issues with { expected_source_string }
1467
+ Note: This error originates from the build backend, and is likely not a problem \
1468
+ with poetry but one of the following issues with { expected_source_string }
1437
1469
1438
1470
- not supporting PEP 517 builds
1439
1471
- not specifying PEP 517 build requirements correctly
0 commit comments