fparser Reference Guide  0.0.14
conftest.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
38 """
39 Shared fixtures.
40 """
41 
42 import logging
43 import fparser.common.tests.logging_utils
44 import pytest
45 
46 
47 @pytest.fixture
48 def log():
49  """
50  Prepare a fixture to capture logged events for inspection.
51  """
52  logger = logging.getLogger("fparser")
53  handler = fparser.common.tests.logging_utils.CaptureLoggingHandler()
54  logger.addHandler(handler)
55  logger.setLevel(logging.DEBUG)
56  yield handler
57  # When the fixture function is a generator, i.e. it uses "yield" rather
58  # than "return", it will be called a second time after the test has
59  # completed. Thus anything appearing after the "yield" is teardown which
60  # happens after the test.
61  logger.removeHandler(handler)