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

Fix typing in cliLogTestBase. #1097

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions python/lsst/daf/butler/tests/cliLogTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import re
import subprocess
import tempfile
import unittest
import unittest.mock
from collections import namedtuple
from collections.abc import Callable
from functools import partial
Expand Down Expand Up @@ -152,8 +152,12 @@
"""

def __init__(self, component: str) -> None:
self.logger = lsstLog.getLogger(component) if lsstLog else None
self.initialLevel = self.logger.getLevel() if lsstLog else None
if lsstLog:
self.logger = lsstLog.getLogger(component)
self.initialLevel = self.logger.getLevel()

Check warning on line 157 in python/lsst/daf/butler/tests/cliLogTestBase.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/tests/cliLogTestBase.py#L156-L157

Added lines #L156 - L157 were not covered by tests
else:
self.logger = None
self.initialLevel = None

def runTest(self, cmd: Callable) -> None:
"""Test that the log context manager works with the butler cli.
Expand Down Expand Up @@ -188,6 +192,8 @@
self.assertEqual(pyLsstRoot.logger.level, logging.INFO)
self.assertEqual(pyButler.logger.level, pyButler.initialLevel)
if lsstLog is not None:
assert lsstRoot.logger is not None
assert lsstButler.logger is not None

Check warning on line 196 in python/lsst/daf/butler/tests/cliLogTestBase.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/tests/cliLogTestBase.py#L195-L196

Added lines #L195 - L196 were not covered by tests
self.assertEqual(lsstRoot.logger.getLevel(), lsstLog.INFO)
# lsstLogLevel can either be the initial level, or uninitialized or
# the defined default value.
Expand Down Expand Up @@ -385,7 +391,7 @@
self.assertIn("DEBUG", records_text[num], str(records_text[num]))
self.assertNotIn("{", records_text[num], str(records_text[num]))

self.assertGreater(len(records), n_records)
self.assertGreater(len(records_text), n_records)

def testLogTty(self) -> None:
"""Verify that log output to terminal can be suppressed."""
Expand Down
Loading