pytest: Configure logging in a fixture to match stdout capturing

pytest captures the output by monkey patching out `sys.stdout`. This may
conflict with our use of `sys.stdout` when configuring logging, resulting in
the "Write to closed file" issue that is spamming the logs. By making the
logging configuration a fixture hopefully we always use the correct
stdout (after pytest has monkey-patched it).
This commit is contained in:
Christian Decker
2020-02-19 17:57:56 +01:00
committed by Rusty Russell
parent cf8c972883
commit 7201cb7315
3 changed files with 15 additions and 7 deletions

View File

@@ -17,7 +17,6 @@ import sqlite3
import string
import struct
import subprocess
import sys
import threading
import time
@@ -69,10 +68,6 @@ SLOW_MACHINE = env("SLOW_MACHINE", "0") == "1"
TIMEOUT = int(env("TIMEOUT", 180 if SLOW_MACHINE else 60))
if TEST_DEBUG:
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
def wait_for(success, timeout=TIMEOUT):
start_time = time.time()
interval = 0.25