pytition / Pytition

Django app for self-hosted privacy-friendly online petitions
https://pytition.org
BSD 3-Clause "New" or "Revised" License
97 stars 28 forks source link

Error when running all tests through Docker #293

Closed Benbb96 closed 2 years ago

Benbb96 commented 2 years ago

When I run the command python manage.py test in the Docker CLI of the container pytition_web_1, I get these errors :

System check identified no issues (0 silenced).
EE
======================================================================
ERROR: pytition.petition (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pytition.petition
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/local/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
ModuleNotFoundError: No module named 'pytition.petition'

======================================================================
ERROR: pytition.pytition (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pytition.pytition
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/local/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
ModuleNotFoundError: No module named 'pytition.pytition'

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (errors=2)

After searching for a while, If found this answer on SO : https://stackoverflow.com/a/67650727/8439435 And after deleting __init__.py file which is under pytition folder, command is now working.

I don't know what are the impacts of deleting this file.

fallen commented 2 years ago

Hello @Benbb96 thanks a lot for the report and for the investigation for the fix :) I've pushed the fix after taking care of testing that it does not break the demo site and testing running tests with and without docker.