cherry
cherry copied to clipboard
fix mock call cache flaky
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