Skip to content

Commit 493104c

Browse files
authored
style: split joined path segments (#331)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent f3af229 commit 493104c

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

tests/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
cyclonedx_lib_name: str = 'cyclonedx-python-lib'
4646
cyclonedx_lib_version: str = version(cyclonedx_lib_name)
4747
single_uuid: str = 'urn:uuid:{}'.format(uuid4())
48-
schema_directory = os.path.join(os.path.dirname(__file__), '../cyclonedx/schema')
48+
schema_directory = os.path.join(os.path.dirname(__file__), '..', 'cyclonedx', 'schema')
4949

5050

5151
class BaseJsonTestCase(TestCase):

tests/test_component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from cyclonedx.model.component import Component
2828
from data import get_component_setuptools_simple
2929

30-
FIXTURES_DIRECTORY = 'fixtures/xml/1.4'
30+
FIXTURES_DIRECTORY = join('fixtures', 'xml', '1.4')
3131

3232

3333
class TestComponent(TestCase):

tests/test_output_json.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,25 @@ def test_bom_v1_2_issue_275_components(self) -> None:
371371
fixture='bom_issue_275_components.json'
372372
)
373373

374-
# Helper methods
374+
# region Helper methods
375+
375376
def _validate_json_bom(self, bom: Bom, schema_version: SchemaVersion, fixture: str) -> None:
376377
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON, schema_version=schema_version)
377378
self.assertEqual(outputter.schema_version, schema_version)
378-
with open(
379-
join(dirname(__file__), f'fixtures/json/{schema_version.to_version()}/{fixture}')) as expected_json:
380-
self.assertValidAgainstSchema(bom_json=outputter.output_as_string(), schema_version=schema_version)
381-
self.assertEqualJsonBom(expected_json.read(), outputter.output_as_string())
382-
expected_json.close()
379+
output = outputter.output_as_string()
380+
self.assertValidAgainstSchema(bom_json=output, schema_version=schema_version)
381+
with open(join(
382+
dirname(__file__),
383+
'fixtures',
384+
'json',
385+
schema_version.to_version(),
386+
fixture
387+
)) as expected_json:
388+
self.assertEqualJsonBom(expected_json.read(), output)
383389

384390
def _validate_json_bom_not_supported(self, bom: Bom, schema_version: SchemaVersion) -> None:
385391
with self.assertRaises(FormatNotSupportedException):
386392
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON, schema_version=schema_version)
387393
outputter.output_as_string()
394+
395+
# endregion Helper methods

tests/test_output_xml.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,20 @@ def test_bom_v1_0_issue_275_components(self) -> None:
515515
fixture='bom_issue_275_components.xml'
516516
)
517517

518-
# Helper methods
518+
# region Helper methods
519+
519520
def _validate_xml_bom(self, bom: Bom, schema_version: SchemaVersion, fixture: str) -> None:
520521
outputter = get_instance(bom=bom, schema_version=schema_version)
521522
self.assertEqual(outputter.schema_version, schema_version)
522-
with open(
523-
join(dirname(__file__), f'fixtures/xml/{schema_version.to_version()}/{fixture}')) as expected_xml:
524-
self.assertValidAgainstSchema(bom_xml=outputter.output_as_string(), schema_version=schema_version)
525-
self.assertEqualXmlBom(
526-
expected_xml.read(), outputter.output_as_string(), namespace=outputter.get_target_namespace()
527-
)
528-
expected_xml.close()
523+
output = outputter.output_as_string()
524+
self.assertValidAgainstSchema(bom_xml=output, schema_version=schema_version)
525+
with open(join(
526+
dirname(__file__),
527+
'fixtures',
528+
'xml',
529+
schema_version.to_version(),
530+
fixture
531+
)) as expected_xml:
532+
self.assertEqualXmlBom(expected_xml.read(), output, namespace=outputter.get_target_namespace())
533+
534+
# endregion Helper methods

0 commit comments

Comments
 (0)