def test_change_level_undo(pytester: Pytester) -> None:
    """Ensure that 'set_level' is undone after the end of the test.

    Tests the logging output themselves (affected both by logger and handler levels).
    """
    pytester.makepyfile(
        """
        import logging

        def test1(caplog):
            caplog.set_level(logging.INFO)
            # using + operator here so fnmatch_lines doesn't match the code in the traceback
            logging.info('log from ' + 'test1')
            assert 0

        def test2(caplog):
            # using + operator here so fnmatch_lines doesn't match the code in the traceback
            logging.info('log from ' + 'test2')
            assert 0
    """
    )
    result = pytester.runpytest()
    result.stdout.fnmatch_lines(["*log from test1*", "*2 failed in *"])
    result.stdout.no_fnmatch_line("*log from test2*")
Ensure that 'set_level' is undone after the end of the test.

    Tests the logging output themselves (affected both by logger and handler levels).
    
testing/logging/test_fixture.py