pytest-watch
pytest-watch copied to clipboard
Logging error when running pytest in pytest-watch
Hello,
When I am running pytest-watch on a Django project. When pytest is wrapped by ptw, I get several error about logger which try to write on a closed file. With just pytest it works.
$ DJANGO_SETTINGS_MODULE=settings.development ptw -- --no-migrations backoff_api --reuse-db
[Mon Sep 7 13:34:11 2020] Running: py.test --no-migrations backoff_api --reuse-db
============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
...
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/backoff_api/serializers/__pycache__/user.cpython-37.pyc.140369074352176', wd=801, mask=IN_MODIFY, cookie=0, name=user.cpython-37.pyc.140369074352176>,)
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/backoff_api/serializers/__pycache__/user.cpython-37.pyc.140369074352176', wd=801, mask=IN_MOVED_FROM, cookie=1276819, name=user.cpython-37.pyc.140369074352176>,)
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/backoff_api/serializers/__pycache__/user.cpython-37.pyc', wd=801, mask=IN_MOVED_TO, cookie=1276819, name=user.cpython-37.pyc>,)
collected 1 item
backoff_api/tests/registration/test_serializers.py . [100%]--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/.pytest_cache/v/cache/stepwise', wd=759, mask=IN_MODIFY, cookie=0, name=stepwise>,)
--- Logging error ---
============================== 1 passed in 0.45s ===============================
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/.pytest_cache/v/cache/stepwise', wd=759, mask=IN_MODIFY, cookie=0, name=stepwise>,)
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/__init__.py", line 1037, in emit
stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
File "/usr/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 89, in run
grouped_events = self._group_events(inotify_events)
File "/my/path/dev/pyenv/api_bo/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 57, in _group_events
logger.debug("in-event %s", inotify_event)
Message: 'in-event %s'
Arguments: (<InotifyEvent: src_path=b'/my/path/dev/django_api_and_backoffice/.pytest_cache/v/cache/nodeids', wd=759, mask=IN_MODIFY, cookie=0, name=nodeids>,)
As you can see these errors are merged with the pytest output making difficult to see the useful information.