from pants.testutil.rule_runner import RuleRunner def test_create_file(rule_runner: RuleRunner) -> None: result = rule_runner.request( CreateFile, [ FileContent('foo.txt', 'Hello, world!'), CreateDirectory('bar'), ], ) assert result.files_created == { 'foo.txt': 'Hello, world!', 'bar': DIRECTORY, # Indicate that this is a directory }
from pants.testutil.rule_runner import RuleRunner def test_create_files(rule_runner: RuleRunner) -> None: result = rule_runner.request( CreateFiles, [ FileContent('foo.txt', 'Hello, world!'), FileContent('bar.txt', 'Goodbye, world!'), ], ) assert result.files_created == { 'foo.txt': 'Hello, world!', 'bar.txt': 'Goodbye, world!', }Here, we're using the `CreateFiles` rule to create two files, `foo.txt` and `bar.txt`, with different content. I couldn't determine the package library as the `pants.testutil.rule_runner` module seems to be internal to the Pants build system.