For a pants integration test using `run_pants` is ...
# plugins
b
For a pants integration test using
run_pants
is there anyway to get a reference to the original file directory before it is moved into the test tmpdir? I have tried a
__file__
in my test file but it is not executed until after it is moved. I need to copy some other files from our monorepo into the test directory in addition to creating some test files
f
You could make the files be
resources
which are then depended on by the
python_tests
target.
Then access the files using
pkgutil.get_data
or equivalent.
b
I’ll have a look and give that a try
hmm that isn’t working. This is the error I get:
Copy code
InvalidFieldException: The 'sources' field in target pants-plugins/internal_plugins/myplugin:tests must not have globs with the pattern `../` because targets can only have sources in the current directory or subdirectories. It was set to: ['../../../folder_i_need']
this is my BUILD file. It wasn’t clear what to set for dependencies when using the
--backend-packages
flag with run pants. This is working minus that fact that I have a hard coded reference to the
folder_i_need
Copy code
python_tests(
  name="tests",
  sources=["../../../folder_i_need"],
  dependencies=[":myplugin"],
)
f
I was suggesting putting put a
resources
target in the other directory and then reference that
resources
target via the
dependencies
field of the
python_tests
target
b
ah okay I will try that when I get back to it
I’m digging out an old plugin I built a while ago but haven’t been working with pants since I built it so I’m a bit rusty on everything right now
something about the way the tests run doesn’t work with referencing anything outside of this directory. either a target defined elsewhere or using a relative path