Skip to content

Commit 01ac58c

Browse files
committed
dings
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent da6ba63 commit 01ac58c

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
_T = TypeVar('_T')
3636

37+
38+
PROJECT_ROOT_DIRECTORY = path.abspath(path.join(path.dirname(__file__), '..'))
39+
PROJECT_LIB_DIRECTORY = path.join(PROJECT_ROOT_DIRECTORY, 'cyclonedx')
40+
PROJECT_LIB_MODELS_DIRECTORY = path.join(PROJECT_LIB_DIRECTORY, 'model')
41+
3742
_TESTDATA_DIRECTORY = path.join(path.dirname(__file__), '_data')
3843

3944
SCHEMA_TESTDATA_DIRECTORY = path.join(_TESTDATA_DIRECTORY, 'schemaTestData')
@@ -199,5 +204,5 @@ def load_pyproject() -> dict[str, Any]:
199204
from tomllib import load as toml_load
200205
else:
201206
from tomli import load as toml_load
202-
with open(path.join(path.dirname(__file__), '..', 'pyproject.toml'), 'rb') as f:
207+
with open(path.join(PROJECT_ROOT_DIRECTORY, 'pyproject.toml'), 'rb') as f:
203208
return toml_load(f)

tests/test_enums.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from cyclonedx.schema import OutputFormat, SchemaVersion
5858
from cyclonedx.schema._res import BOM_JSON as SCHEMA_JSON, BOM_XML as SCHEMA_XML
5959
from cyclonedx.validation import make_schemabased_validator
60-
from tests import SnapshotMixin
60+
from tests import PROJECT_LIB_MODELS_DIRECTORY, SnapshotMixin
6161
from tests._data.models import _make_bom
6262

6363
# region SUT: all the enums
@@ -1006,10 +1006,9 @@ def __get_defined_enumcases(cls) -> tuple[str, ...]:
10061006

10071007
@staticmethod
10081008
def __get_defined_model_enums() -> Generator[tuple[str, str], None, None]:
1009-
models_path = path.abspath(path.join(path.dirname(__file__), '..', 'cyclonedx', 'model'))
1010-
model_files = glob(path.join(models_path, '**', '*.py'), recursive=True)
1009+
model_files = glob(path.join(PROJECT_LIB_MODELS_DIRECTORY, '**', '*.py'), recursive=True)
10111010
for model_file in model_files:
1012-
model_file_rel = path.relpath(model_file, models_path)
1011+
model_file_rel = path.relpath(model_file, PROJECT_LIB_MODELS_DIRECTORY)
10131012
with open(model_file, encoding='utf-8') as f:
10141013
tree = ast.parse(f.read(), filename=model_file)
10151014
for node in ast.walk(tree):

0 commit comments

Comments
 (0)