Skip to content

Commit 4bbfd2d

Browse files
Lorak-mmkfruch
authored andcommitted
tests: Don't add StreamHandler to logger
Adding this handler causes at least 2 problems: - pytest captures logging calls by itself, so every log is captured twice - once in stderr, once in stdlog - logging calls in atexit handlers fail - as they are trying to write to a closed stream. Original purpose of the code seems to be to allow log capture for nose, but we no longer use nose. It also specified log level and format - but those can be specified using pytest.ini (which this commit also adds), so the code can be removed now.
1 parent 1e9a383 commit 4bbfd2d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pytest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pytest]
2+
log_format = %(asctime)s.%(msecs)03d %(levelname)s [%(module)s:%(lineno)s]: %(message)s
3+
log_level = DEBUG
4+
log_date_format = %Y-%m-%d %H:%M:%S

tests/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
from concurrent.futures import ThreadPoolExecutor
2222

2323
log = logging.getLogger()
24-
log.setLevel('DEBUG')
25-
# if nose didn't already attach a log handler, add one here
26-
if not log.handlers:
27-
handler = logging.StreamHandler()
28-
handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s [%(module)s:%(lineno)s]: %(message)s'))
29-
log.addHandler(handler)
30-
3124

3225
def is_eventlet_monkey_patched():
3326
if 'eventlet.patcher' not in sys.modules:

0 commit comments

Comments
 (0)