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

Fix functional tests #174

Merged
merged 1 commit into from
Aug 17, 2022
Merged

Fix functional tests #174

merged 1 commit into from
Aug 17, 2022

Conversation

sea-kelp
Copy link
Collaborator

@sea-kelp sea-kelp commented Aug 17, 2022

Description of Changes

Bug:

  • pytest 6.2.0 introduced a change that warns about unhandled thread exceptions, which likely means that the tests were erroring before we upgraded and just weren't aware of it: https://docs.pytest.org/en/7.1.x/changelog.html#id129
  • Currently, we try to create a new flask thread for each functional test and since they all try to use the same port, all but the first thread to throws this error:
    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

tests/test_functional.py::test_officer_form_has_units_alpha_sorted
  /usr/local/lib/python3.10/site-packages/_pytest/threadexception.py:75: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-295 (run)
  
  Traceback (most recent call last):
    File "/usr/local/lib/python3.10/site-packages/werkzeug/serving.py", line 911, in prepare_socket
      s.bind(server_address)
  OSError: [Errno 98] Address already in use
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
      self.run()
    File "/usr/local/lib/python3.10/threading.py", line 953, in run
      self._target(*self._args, **self._kwargs)
    File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 920, in run
      run_simple(t.cast(str, host), port, self, **options)
    File "/usr/local/lib/python3.10/site-packages/werkzeug/serving.py", line 1062, in run_simple
      s = prepare_socket(hostname, port)
    File "/usr/local/lib/python3.10/site-packages/werkzeug/serving.py", line 930, in prepare_socket
      sys.exit(1)
  SystemExit: 1

Change:

  • Set flask app fixture scope to "session" so we don't try to run multiple instances on the same port

Notes for Deployment

None!

Screenshots (if appropriate)

N/A

Tests and linting

  • I have rebased my changes on main

  • just lint passes

  • just test passes

@sea-kelp sea-kelp marked this pull request as ready for review August 17, 2022 04:44
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, what a find! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants