Reputation: 26
I’m encountering an issue running unit tests for my Django project on GitHub Actions. The tests run fine on my local machine using Docker containers, but I’m facing errors when running tests on GitHub Actions.
Issue Description:
In my CI/CD configuration file (GitHub Actions), I encounter an error when attempting to run tests. Here is a snippet of the error I’m receiving:
======================================================================
ERROR: AHC_app.AHC_app (unittest.loader._FailedTest.AHC_app.AHC_app)
----------------------------------------------------------------------
ImportError: Failed to import test module: AHC_app.AHC_app
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/unittest/loader.py", line 429, in _find_test_path
package = self._get_module_from_name(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/unittest/loader.py", line 339, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'AHC_app.AHC_app'
What I’ve Tried:
1. Setting PYTHONPATH: I’ve experimented with different configurations for the PYTHONPATH environment variable to point to the module locations, but I encounter the same error. Below are some examples of configurations I’ve tried:
2. _init_.py Files: I verified that all necessary _init_.py files are present, confirming the project structure is correct.
What I Need Help With:
Has anyone experienced similar issues with importing modules when running tests on GitHub Actions? What could be causing the ModuleNotFoundError, and what are best practices for configuring PYTHONPATH in the context of GitHub Actions?
Additional Context:
I am using Docker Compose for containerization and optionally deploying Kubernetes on Minikube.
Files:
GitHub Actions Configuration File
Thank you in advance for any assistance!
Upvotes: 0
Views: 30