From 2cceb3b568b22a01e973cf1195882f09e50620a9 Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Fri, 3 Feb 2023 22:46:41 -0300 Subject: [PATCH] Fix #94 Get cache from disk to avoid cache overwriting. --- pytest_flake8.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pytest_flake8.py b/pytest_flake8.py index 2555f8a..fd0317c 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -80,8 +80,10 @@ def pytest_collect_file(file_path, path, parent): def pytest_unconfigure(config): """Flush cache at end of run.""" - if hasattr(config, "_flake8mtimes"): - config.cache.set(HISTKEY, config._flake8mtimes) + if hasattr(config, "_flake8mtimes") and config._flake8mtimes: + cache = config.cache.get(HISTKEY, {}) + cache.update(config._flake8mtimes) + config.cache.set(HISTKEY, cache) class Flake8Error(Exception):