bazel test can't import `requests` package (with 0.1.0 pip_install rule) #380
Comments
Hey @chartinmarrel, firstly thanks for the reproduction. Made it much easier to follow up your issue. Your problem here is not particular to the I made this change in your if __name__ == '__main__':
# loader = unittest.TestLoader()
# suite = loader.discover(".")
# runner = unittest.TextTestRunner()
# sys.exit(not runner.run(suite).wasSuccessful())
unittest.main() and the tests pass. When I look in Is there a particular reason you're using unittest's test discovery? It's behaviour it not compatible with Bazel. |
As a bit of extra detail, If we look at this line: What this shows is that it's tried to import a Python file under |
Thanks for the explanation!
Here is the content of the
When I run Is there another way to use |
Actually a colleague of mine noticed that I could use my initial code if I replace
This will not mess up with dependency resolution |
Yeah this is expected, as Bazel is not designed to discover and run tests that aren't statically defined as included in a There's Are you happy if I close this issue, as it's not a problem with the importing of |
Affected Rule
The issue is caused by the rule: pip_installIs this a regression?
It is specific to the new way (v0.1.0) of install pip dependencies
Description
Followed 0.1.0 migration guide and tried it with a simple python package that has the python requirement
requests
.When I run
bazel test //...
it fails with errors:I forked the repo to host my example code.
If I run
bazel build //...
and thenbazel-bin/test_main
, the test succeed with no error.Operating System:
macOS Catalina 10.15.7
Output of
bazel version
:Rules_python version:
0.1.0
Anything else relevant?
The text was updated successfully, but these errors were encountered: