Skip to content

Commit

Permalink
janky ass warnings test
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Nov 12, 2024
1 parent c724731 commit 9569af7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ def test_nested_loggers(capsys, tmp_path):
child.debug("hey")
parent.debug("sup")

warnings.warn(f"FILES IN LOG DIR: {list(log_dir.glob('*'))}")
root_logger = logging.getLogger("miniscope_io")

with open(log_dir / "miniscope_io.log") as lfile:
file_logs = lfile.read()
warnings.warn(f"FILES IN LOG DIR: {list(log_dir.glob('*'))}")
warnings.warn(f"ROOT LOGGER HANDLERS: {root_logger.handlers}")

root_logger = logging.getLogger("miniscope_io")
assert len(root_logger.handlers) == 2
assert len(parent.handlers) == 0
assert len(child.handlers) == 0

with open(log_dir / "miniscope_io.log") as lfile:
file_logs = lfile.read()

# only one message of each!
stdout = capsys.readouterr()
assert len(re.findall("hey", stdout.out)) == 1
Expand Down

0 comments on commit 9569af7

Please sign in to comment.