diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-08-21 14:06:28 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-21 14:06:28 -0500 |
| commit | ff5224728484eb4f3bbf6ae52fe0b79f64959660 (patch) | |
| tree | 71b3e53e0080da60abf9fd2381705971dfe4d507 /tests/unit/modules/base.py | |
| parent | 7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff (diff) | |
| parent | 45dc95873fd906c582fbbd5e6ca3838caf867399 (diff) | |
| download | rest.vyos-ff5224728484eb4f3bbf6ae52fe0b79f64959660.tar.gz rest.vyos-ff5224728484eb4f3bbf6ae52fe0b79f64959660.zip | |
Merge pull request #16 from vyos/T8989_wave4
T8989: wave4 vyos_command, dict_op refactor
Diffstat (limited to 'tests/unit/modules/base.py')
| -rw-r--r-- | tests/unit/modules/base.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unit/modules/base.py b/tests/unit/modules/base.py index 4d49fbb..a3e2eeb 100644 --- a/tests/unit/modules/base.py +++ b/tests/unit/modules/base.py @@ -13,12 +13,23 @@ import unittest from unittest.mock import MagicMock # noqa: F401 +_fixture_cache = {} + + def load_fixture(filename): - """Load a JSON fixture file from tests/unit/fixtures/.""" + """Load a fixture file from tests/unit/fixtures/. Results are cached.""" fixtures_dir = os.path.join(os.path.dirname(__file__), "..", "fixtures") path = os.path.join(fixtures_dir, filename) + if path in _fixture_cache: + return _fixture_cache[path] with open(path) as f: - return json.load(f) + data = f.read() + try: + data = json.loads(data) + except json.JSONDecodeError: + pass + _fixture_cache[path] = data + return data class VyOSModuleTestCase(unittest.TestCase): |
