Closed Bug 1423223 Opened 7 years ago Closed 4 years ago

upgrade to pytest 3.3.0 and drop logging_mock

Categories

(Socorro :: Antenna, task, P3)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: willkg, Assigned: willkg)

Details

Attachments

(1 file)

pytest 3.3.0 has its own caplog fixture now: """ Pytest now captures and displays output from the standard logging module. The user can control the logging level to be captured by specifying options in pytest.ini, the command line and also during individual tests using markers. Also, a caplog fixture is available that enables users to test the captured log during specific tests (similar to capsys for example). For more information, please see the logging docs. This feature was introduced by merging the popular pytest-catchlog plugin, thanks to Thomas Hisch. Be advised that during the merging the backward compatibility interface with the defunct pytest-capturelog has been dropped. (#2794) """ This bug covers updating Antenna to pytest 3.3.0 and rewriting the tests that look at logging to use caplog.
I did a pass on updating requirements and Antenna is now using pytest 3.6.1. I didn't drop the logging_mock--that still needs to be done.
Marking this as [good first bug] since it's pretty straight-forward.
Priority: -- → P3
Whiteboard: [good first bug]
It's not quite "straight-forward". Antenna's app gets rebuilt in the tests. When that happens, it calls setup_logging() which then reconfigures logging. At test setup, pytest patches logging to capture it and the caplog fixture lets you view that logging. But since setup_logging() reconfigures logging during the test, pytest's logging instrumentation is tossed out and then caplog doesn't know about any of the logging that happened. Some possible options: 1. we can keep our logging mock 2. we can change setup_logging() to be a "once-a-process-lifetime" kind of thing and keep track of the fact it's been called already 3. we can change setup_logging() to realize it's already configured logging and just fix the things that could change 4. we can tinker with this more and figure out how to coerce pytest to re-instrument logging during the test 5. some fourth thing Item 3 seems like a good idea. It's the most "correct" and lowest maintenance option of the bunch. Grabbing this to do.
Assignee: nobody → willkg
Status: NEW → ASSIGNED
Whiteboard: [good first bug]

Unassigning myself since I'm not going to get to this any time soon.

Assignee: willkg → nobody
Status: ASSIGNED → NEW
Assignee: nobody → willkg

Most of the code changes here only affect the tests. However, I did go with option 2 where I changed setup_logging() so it only sets up logging once-a-process-lifetime. I'm pretty sure that'll be fine, but it means that this needs to wait to go to prod until I can mark it FIXED.

This was deployed to prod in bug #1661072. Marking as FIXED.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: