Howdy! I have a python package that can successfully execute tests locally. When I run it in Travis in its main Github repository (public), it fails with import errors on the test classes/modules:
ERROR: django_presskit.tests.test_views (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: django_presskit.tests.test_views
Traceback (most recent call last):
File "/opt/python/2.7.14/lib/python2.7/unittest/loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "/opt/python/2.7.14/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
__import__(name)
ImportError: No module named tests.test_views
I have debugging enabled on the public repo, but I wasn’t particularly sure of what to try once I SSH’d in. Running the stages manually just produced the error again.
With the exact same code and configuration (verified via a diff of the folders) succeeding in a private repo and not on a public one, there must be something different between the Travis environments between the two, right? I’m pretty stumped.
Do you have a URL to the private repo build that succeeds? If I go through the commands with my Docker image, the command fails similarly, so I am guessing that it is broken, but the private one has some critical difference that makes it go.
Thanks for the information. I also confirmed that “averymd/improved-sniffle” passes when I run the commands in question, consistent with your report.
This points to the correct behavior on our system, and the issue(s) in your “FutureProofGames” repository.
I don’t know enough about Python to give you meaningful advice, but if you compare the two repositories I get a few differences that might point you to revelation.
Thank you so much for the comparison! Is there a way for me to perform a diff like that myself of what’s on the travis boxes?
The crux of the issue is:
Only in averymd/improved-sniffle/tests: test_dpk_util.pyc
Only in averymd/improved-sniffle/tests: test_models.pyc
Only in averymd/improved-sniffle/tests: test_views.pyc
Since python isn’t finding the source files, it’s not compiling them. The source files are definitely on the server, of course.
As for the rest of the diff: python bytecode files will be different even if the underlying code is the same, unfortunately. Those commits also don’t quite line up (they include some later experiments/attempts in the FutureProofGames version).
Update: the issue was caused by the repo having the exact same name as the library that’s installed. Changing the repo from django_presskit to django-presskit resolved the issue.
Thank you to everyone who offered suggestions and methods to troubleshoot this.