diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py index ffa6fb43e..47640ced3 100644 --- a/pint/facets/plain/registry.py +++ b/pint/facets/plain/registry.py @@ -534,7 +534,9 @@ def _build_cache(self, loaded_files=None) -> None: if cache is None: self._build_cache() diskcache.save(self._cache, loaded_files, "build_cache") - return + else: + self._cache = cache + return self._cache = RegistryCache() diff --git a/pint/testsuite/test_diskcache.py b/pint/testsuite/test_diskcache.py index 399f9f765..ed5557a52 100644 --- a/pint/testsuite/test_diskcache.py +++ b/pint/testsuite/test_diskcache.py @@ -95,3 +95,13 @@ def test_change_file(tmp_path): assert ureg.x == 1235 files = tuple(ureg._diskcache.cache_folder.glob("*.pickle")) assert len(files) == 4 + + +def test_dimensional_equivalent_are_cached(tmp_path): + ureg = pint.UnitRegistry(cache_folder=tmp_path) + t = ureg.get_compatible_units("L") + assert len(t) > 0 + + ureg = pint.UnitRegistry(cache_folder=tmp_path) + t = ureg.get_compatible_units("L") + assert len(t) > 0