from pants.testutil.rule_runner import RuleRunner from my_project.targets import MyTarget def test_my_target_rule(): rule_runner = RuleRunner() target_address = "my_project/my_target" target = rule_runner.get_target(target_address) assert isinstance(target, MyTarget)
from pants.testutil.rule_runner import RuleRunner def test_invalid_target(): rule_runner = RuleRunner() target_address = "my_project/invalid_target" with pytest.raises(ValueError): rule_runner.get_target(target_address)In this example, we are using `get_target` to retrieve a non-existent target at address `my_project/invalid_target`. We expect `get_target` to raise a `ValueError` since the target does not exist. Based on the package and module name, `pants.testutil.rule_runner` appears to be part of the `pantsbuild/pants` library.