Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests fail to run when other test arguments are passed #179

Closed
wookie184 opened this issue Jun 22, 2023 · 0 comments · Fixed by #180
Closed

Integration tests fail to run when other test arguments are passed #179

wookie184 opened this issue Jun 22, 2023 · 0 comments · Fixed by #180
Assignees
Labels
area: tests Related to tests (e.g. unit tests) priority: 2 - normal

Comments

@wookie184
Copy link
Contributor

Running python -m unittest tests/test_integration.py gives this error

root@snekbox_dev:/snekbox# while true; do python -m unittest tests/test_integration.py; done
/root/.local/lib/python3.11/site-packages/falcon/media/__init__.py:4: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
  from .handlers import Handlers
2023-06-22 11:59:55,203 |  8983 |                 gunicorn.error |    ERROR | Exception in worker process
Traceback (most recent call last):
  File "/root/.local/lib/python3.11/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tests/test_integration'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/root/.local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/root/.local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
                ^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
                    ^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
           ^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/gunicorn/util.py", line 363, in import_app
    raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
ImportError: Failed to find application, did you mean 'tests/test_integration:application'?

The issue is that the gunicorn process is inheriting the command line arguments used to run the tests and attempting to use them itself. I think setting sys.argv = [""] in the subprocess is the easiest fix (a bit hacky but it seems to work fine)

@wookie184 wookie184 added area: tests Related to tests (e.g. unit tests) priority: 2 - normal labels Jun 22, 2023
@wookie184 wookie184 self-assigned this Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tests Related to tests (e.g. unit tests) priority: 2 - normal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant