From e294cbaa1135be460b51325236ad277988b7bc69 Mon Sep 17 00:00:00 2001 From: Olivier Cervello Date: Tue, 23 Apr 2024 06:59:37 -0400 Subject: [PATCH] update --- secator/__init__.py | 4 ++-- tests/unit/test_offline.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/secator/__init__.py b/secator/__init__.py index 14822738..0f30288d 100644 --- a/secator/__init__.py +++ b/secator/__init__.py @@ -7,7 +7,7 @@ import requests import yaml from dotmap import DotMap -from pydantic import AfterValidator, BaseModel, model_validator, ValidationError, Extra +from pydantic import AfterValidator, BaseModel, model_validator, ValidationError from secator.rich import console, console_stdout @@ -19,7 +19,7 @@ CONFIGS_FOLDER = LIB_FOLDER / 'configs' -class StrictModel(BaseModel, extra=Extra.forbid): +class StrictModel(BaseModel, extra='forbid'): pass diff --git a/tests/unit/test_offline.py b/tests/unit/test_offline.py index 61117e6e..50f01860 100644 --- a/tests/unit/test_offline.py +++ b/tests/unit/test_offline.py @@ -1,9 +1,17 @@ import os +import sys import unittest class TestOffline(unittest.TestCase): def setUp(self): + try: + # This allows to drop the secator module loaded from other tests in order to reload the config with modified + # environment variables. + # See https://stackoverflow.com/questions/7460363/re-import-module-under-test-to-lose-context for context. + del sys.modules['secator'] + except KeyError: + pass os.environ['SECATOR_OFFLINE_MODE'] = '1' def test_offline_cve_lookup(self):