Skip to content

Commit 3601300

Browse files
committed
pants-plugins/pack_metadata: add test for inject_extra_sys_path_for_pack_tests rule
1 parent 6d78136 commit 3601300

1 file changed

Lines changed: 48 additions & 3 deletions

File tree

pants-plugins/pack_metadata/python_rules/python_path_rules_test.py

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
# limitations under the License.
1414

1515
import pytest
16-
from pants.engine.internals.native_engine import Address
16+
from pants.backend.python.goals.pytest_runner import PytestPluginSetup
17+
from pants.engine.internals.native_engine import Address, EMPTY_DIGEST
1718
from pants.testutil.rule_runner import RuleRunner
1819

1920
from pack_metadata.python_rules.python_path_rules import (
2021
PackPythonPath,
2122
PackPythonPathRequest,
23+
PytestPackTestRequest,
2224
)
2325

2426

@@ -120,5 +122,48 @@ def test_get_extra_sys_path_for_pack_dependencies(
120122
assert pack_python_path.entries == expected
121123

122124

123-
def test_inject_extra_sys_path_for_pack_tests(rule_runner: RuleRunner) -> None:
124-
pass
125+
@pytest.mark.xfail(raises=AttributeError, reason="Not implemented in pants yet.")
126+
@pytest.mark.parametrize(
127+
"address,expected",
128+
(
129+
(
130+
Address("packs/foo/tests", relative_file_path="test_get_bar_action.py"),
131+
("packs/foo/actions",),
132+
),
133+
(
134+
Address("packs/foo/tests", relative_file_path="test_get_baz_action.py"),
135+
("packs/foo/actions",),
136+
),
137+
(
138+
Address(
139+
"packs/dr_seuss/tests",
140+
relative_file_path="test_get_from_actions_lib_action.py",
141+
),
142+
("packs/dr_seuss/actions", "packs/dr_seuss/actions/lib"),
143+
),
144+
(
145+
Address(
146+
"packs/shards/tests",
147+
relative_file_path="test_get_from_pack_lib_action.py",
148+
),
149+
("packs/shards/actions", "packs/shards/lib"),
150+
),
151+
(
152+
Address(
153+
"packs/shards/tests", relative_file_path="test_horn_eater_sensor.py"
154+
),
155+
("packs/shards/sensors", "packs/shards/lib"),
156+
),
157+
(
158+
Address("packs/metals/tests", relative_file_path="test_fly_action.py"),
159+
("packs/metals/actions/mist_born", "packs/metals/actions"),
160+
),
161+
),
162+
)
163+
def test_inject_extra_sys_path_for_pack_tests(
164+
rule_runner: RuleRunner, address: Address, expected: tuple[str, ...]
165+
) -> None:
166+
target = rule_runner.get_target(address)
167+
result = rule_runner.request(PytestPluginSetup, (PytestPackTestRequest(target),))
168+
assert result.digest == EMPTY_DIGEST
169+
assert result.extra_sys_path == expected

0 commit comments

Comments
 (0)