cherry icon indicating copy to clipboard operation
cherry copied to clipboard

fix mock call cache flaky

Open jzysak25 opened this issue 4 years ago • 0 comments

There is a flaky test in ClassifyTest test_init by running:

pytest --flake-finder

The failed test is due to the uncleaned cache for test rerunning. When cache existed, the _load_cache will not be called and the assertion will fail failed to assert:

mock_load.assert_called_once_with('random')

Solution: added a getter to see whether the cache is created.

Changed code passed all flaky rerun and normal pytest runs

jzysak25 avatar Oct 24 '21 22:10 jzysak25