3 Commits
Author SHA1 Message Date
jakob.scheid 9651e29a91 test(python-generator): add test cases for package namespace comparision
Added test cases with different types for Python package namespace
comparision test.
2026-09-27 22:07:58 +02:00
jakob.scheid 9941649841 feat(python-generator): check type at package namespace comparision
Added type check to the Python package namespace comparision function.
2026-09-27 22:07:12 +02:00
jakob.scheid c55238a1c1 test(python-generator): add test cases for module namespace comparision
Added test cases with different types for Python module namespace
comparision test.
2026-09-27 22:04:32 +02:00
3 changed files with 31 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ class PythonPackageNamespace(PythonNamespace):
# For performance reasons, is not called self.sub_namespace_names # For performance reasons, is not called self.sub_namespace_names
# if the name attribute does not match, which can be quickly # if the name attribute does not match, which can be quickly
# verified # verified
if self.name != value.name: if not (isinstance(value, type(self)) and self.name == value.name):
return False return False
return value.sub_namespace_names() == self.sub_namespace_names() return value.sub_namespace_names() == self.sub_namespace_names()
@@ -14,7 +14,11 @@
import pytest import pytest
from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace from src.jcloud_docsgen.core.python.namespaces import (
PythonNamespace,
PythonModuleNamespace,
PythonPackageNamespace,
)
class StrSubclass(str): ... class StrSubclass(str): ...
@@ -42,6 +46,10 @@ def test_PythonModuleNamespace_name_attribute(namespace, expected_name):
(PythonModuleNamespace('a'), PythonModuleNamespace('b'), False), (PythonModuleNamespace('a'), PythonModuleNamespace('b'), False),
(PythonModuleNamespace('0'), PythonModuleNamespace('-0'), False), (PythonModuleNamespace('0'), PythonModuleNamespace('-0'), False),
(PythonModuleNamespace('1'), PythonModuleNamespace('a'), False), (PythonModuleNamespace('1'), PythonModuleNamespace('a'), False),
(PythonModuleNamespace('a'), 'a', False),
(PythonModuleNamespace('a'), 'b', False),
(PythonModuleNamespace('a'), PythonPackageNamespace('a', []), False),
(PythonModuleNamespace('a'), PythonNamespace('a'), False),
], ],
) )
def test_PythonModuleNamespace___eq__(namespace1, namespace2, expected): def test_PythonModuleNamespace___eq__(namespace1, namespace2, expected):
@@ -15,6 +15,7 @@
import pytest import pytest
from src.jcloud_docsgen.core.python.namespaces import ( from src.jcloud_docsgen.core.python.namespaces import (
PythonNamespace,
PythonModuleNamespace, PythonModuleNamespace,
PythonPackageNamespace, PythonPackageNamespace,
) )
@@ -256,6 +257,26 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
PythonPackageNamespace('b', []), PythonPackageNamespace('b', []),
False, False,
), ),
(
PythonPackageNamespace('a', []),
'a',
False,
),
(
PythonPackageNamespace('a', []),
'b',
False,
),
(
PythonPackageNamespace('a', []),
PythonModuleNamespace('a'),
False,
),
(
PythonPackageNamespace('a', []),
PythonNamespace('a'),
False,
),
], ],
) )
def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected): def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):