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

Use of capsys causes log access errors on unit test failures #204

Open
ca-johnson opened this issue Oct 26, 2020 · 0 comments
Open

Use of capsys causes log access errors on unit test failures #204

ca-johnson opened this issue Oct 26, 2020 · 0 comments

Comments

@ca-johnson
Copy link
Contributor

noticed in #203

When unit tests fail, there is an issue where log file is closed prior to test exiting.

Example error:

Message: 'p4 sync --parallel=threads=0 //...'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File "/Users/carl/.pyenv/versions/3.6.0/lib/python3.6/logging/__init__.py", line 989, in emit
    stream.write(msg)
ValueError: I/O operation on closed file.

Repro caused by removing one of the with exception blocks in a unit test (or adding one where an exception is not raised)

I was able to track this down to the use of capsys in test_server_fixture

If we remove such usage, the issue is resolved. However, it is quite convenient to print to stdout the server address.

Suggested solutions:

  • Find a workaround to allow continued use of capsys
  • Remove use of capsys, add to instructions in test_server_fixture to run pytest with a special flag to disable output capturing so you can still see the test server address printed to stdout
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

No branches or pull requests

1 participant