OpenFreeEnergy / OpenFreeEnergy/openfe

Issue with `test_main_log` and `test_log_system_probe_unconfigured` test

Open
#643 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
331
Forks
56
Avg merge
3d 9h
Merged PRs (30d)
13

Description

The error message:

    def test_log_system_probe_unconfigured():
        # if probe loggers aren't configured to run, then we shouldn't even call
        # _probe_system()
        logger_names = [
            'openfe.utils.system_probe.log',
            'openfe.utils.system_probe.log.gpu',
            'openfe.utils.system_probe.log.hostname',
        ]
        # check that initial conditions are as expected
        for logger_name in logger_names:
            logger = logging.getLogger(logger_name)
>           assert not logger.isEnabledFor(logging.DEBUG)
E           assert not True
E            +  where True = <bound method Logger.isEnabledFor of <Logger openfe.utils.system_probe.log (DEBUG)>>(10)
E            +    where <bound method Logger.isEnabledFor of <Logger openfe.utils.system_probe.log (DEBUG)>> = <Logger openfe.utils.system_probe.log (DEBUG)>.isEnabledFor
E            +    and   10 = logging.DEBUG

To reproduce:

$ pytest --pyargs openfecli --pyargs openfe -v -k "test_log_system_probe_unconfigured or test_main_log"
tests/test_cli.py::test_main_log[True] PASSED                            [ 33%]
tests/test_cli.py::test_main_log[False] PASSED                           [ 66%]
tests/utils/test_system_probe.py::test_log_system_probe_unconfigured FAILED [100%]

If you swap the order we run the tests in, the error goes away.

$ pytest --pyargs openfe --pyargs openfecli -v -k "test_log_system_probe_unconfigured or test_main_log"
tests/utils/test_system_probe.py::test_log_system_probe_unconfigured PASSED [ 33%]
tests/test_cli.py::test_main_log[True] PASSED                            [ 66%]
tests/test_cli.py::test_main_log[False] PASSED                           [100%]

I discovered this while fixing #610

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the pytest command shown for tests/test_cli.py::test_main_log and tests/utils/test_system_probe.py::test_log_system_probe_unconfigured in both orders. Read those tests and the logging setup they exercise, then identify why logger state persists between tests. Done means both tests pass consistently regardless of collection order.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.