generated from jCloud/repository-template
style: format source code using Ruff
This commit is contained in:
41 files changed
+6061
-5670
No files matched your search
@@ -15,33 +15,49 @@
|
||||
from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace
|
||||
import pytest
|
||||
|
||||
|
||||
class StrSubclass(str): ...
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected_name', [
|
||||
(PythonModuleNamespace('a'), 'a'),
|
||||
(PythonModuleNamespace('1'), '1'),
|
||||
(PythonModuleNamespace(StrSubclass('a')), StrSubclass('a')),
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected_name',
|
||||
[
|
||||
(PythonModuleNamespace('a'), 'a'),
|
||||
(PythonModuleNamespace('1'), '1'),
|
||||
(PythonModuleNamespace(StrSubclass('a')), StrSubclass('a')),
|
||||
],
|
||||
)
|
||||
def test_PythonModuleNamespace_name_attribute(namespace, expected_name):
|
||||
assert namespace.name == expected_name
|
||||
|
||||
@pytest.mark.parametrize('namespace1,namespace2,expected', [
|
||||
(PythonModuleNamespace('a'), PythonModuleNamespace('a'), True),
|
||||
(PythonModuleNamespace('b'), PythonModuleNamespace('b'), True),
|
||||
(PythonModuleNamespace('1'), PythonModuleNamespace('1'), True),
|
||||
(PythonModuleNamespace('42'), PythonModuleNamespace('42'), True),
|
||||
(PythonModuleNamespace('a'), PythonModuleNamespace('b'), False),
|
||||
(PythonModuleNamespace('0'), PythonModuleNamespace('-0'), False),
|
||||
(PythonModuleNamespace('1'), PythonModuleNamespace('a'), False),
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace1,namespace2,expected',
|
||||
[
|
||||
(PythonModuleNamespace('a'), PythonModuleNamespace('a'), True),
|
||||
(PythonModuleNamespace('b'), PythonModuleNamespace('b'), True),
|
||||
(PythonModuleNamespace('1'), PythonModuleNamespace('1'), True),
|
||||
(PythonModuleNamespace('42'), PythonModuleNamespace('42'), True),
|
||||
(PythonModuleNamespace('a'), PythonModuleNamespace('b'), False),
|
||||
(PythonModuleNamespace('0'), PythonModuleNamespace('-0'), False),
|
||||
(PythonModuleNamespace('1'), PythonModuleNamespace('a'), False),
|
||||
],
|
||||
)
|
||||
def test_PythonModuleNamespace___eq__(namespace1, namespace2, expected):
|
||||
assert (namespace1 == namespace2) == expected
|
||||
assert (namespace2 == namespace1) == expected
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected', [
|
||||
(PythonModuleNamespace('a'), 'PythonModuleNamespace(\'a\')'),
|
||||
(PythonModuleNamespace('1'), 'PythonModuleNamespace(\'1\')'),
|
||||
(PythonModuleNamespace(StrSubclass('a')), 'PythonModuleNamespace(\'a\')'),
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected',
|
||||
[
|
||||
(PythonModuleNamespace('a'), "PythonModuleNamespace('a')"),
|
||||
(PythonModuleNamespace('1'), "PythonModuleNamespace('1')"),
|
||||
(
|
||||
PythonModuleNamespace(StrSubclass('a')),
|
||||
"PythonModuleNamespace('a')",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_PythonModuleNamespace_string_representation(namespace, expected):
|
||||
assert repr(namespace) == expected
|
||||
@@ -15,20 +15,29 @@
|
||||
from src.jcloud_docsgen.core.python.namespaces import PythonNamespace
|
||||
import pytest
|
||||
|
||||
|
||||
class StrSubclass(str): ...
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected_name', [
|
||||
(PythonNamespace('a'), 'a'),
|
||||
(PythonNamespace('1'), '1'),
|
||||
(PythonNamespace(StrSubclass('a')), StrSubclass('a')),
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected_name',
|
||||
[
|
||||
(PythonNamespace('a'), 'a'),
|
||||
(PythonNamespace('1'), '1'),
|
||||
(PythonNamespace(StrSubclass('a')), StrSubclass('a')),
|
||||
],
|
||||
)
|
||||
def test_PythonNamespace_name_attribute(namespace, expected_name):
|
||||
assert namespace.name == expected_name
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected', [
|
||||
(PythonNamespace('a'), 'PythonNamespace(\'a\')'),
|
||||
(PythonNamespace('1'), 'PythonNamespace(\'1\')'),
|
||||
(PythonNamespace(StrSubclass('a')), 'PythonNamespace(\'a\')'),
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected',
|
||||
[
|
||||
(PythonNamespace('a'), "PythonNamespace('a')"),
|
||||
(PythonNamespace('1'), "PythonNamespace('1')"),
|
||||
(PythonNamespace(StrSubclass('a')), "PythonNamespace('a')"),
|
||||
],
|
||||
)
|
||||
def test_PythonNamespace_string_representation(namespace, expected):
|
||||
assert repr(namespace) == expected
|
||||
@@ -22,38 +22,47 @@ from src.jcloud_docsgen.exceptions import (
|
||||
InvalidNamespaceError,
|
||||
)
|
||||
|
||||
|
||||
class StrSubclass(str): ...
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected_name', [
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected_name',
|
||||
[
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[],
|
||||
),
|
||||
'a',
|
||||
[],
|
||||
),
|
||||
'a',
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'1',
|
||||
[],
|
||||
),
|
||||
'1',
|
||||
[],
|
||||
),
|
||||
'1',
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
StrSubclass('a'),
|
||||
[],
|
||||
),
|
||||
StrSubclass('a'),
|
||||
[],
|
||||
),
|
||||
StrSubclass('a'),
|
||||
),
|
||||
])
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
|
||||
assert namespace.name == expected_name
|
||||
|
||||
|
||||
namespace_b = PythonModuleNamespace('b')
|
||||
namespace_a = PythonPackageNamespace('a', [
|
||||
namespace_b,
|
||||
])
|
||||
namespace_a = PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
namespace_b,
|
||||
],
|
||||
)
|
||||
namespace_c = PythonModuleNamespace('c')
|
||||
namespace_k = PythonModuleNamespace('k')
|
||||
namespace_j = PythonPackageNamespace('j', [namespace_k])
|
||||
@@ -64,47 +73,51 @@ namespace_f = PythonPackageNamespace('f', [namespace_g])
|
||||
namespace_e = PythonPackageNamespace('e', [namespace_f])
|
||||
namespace_d = PythonPackageNamespace('d', [namespace_e])
|
||||
|
||||
@pytest.mark.parametrize('namespace,sub_namespaces,expected', [
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,sub_namespaces,expected',
|
||||
[
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
),
|
||||
['c'],
|
||||
namespace_c,
|
||||
),
|
||||
['c'],
|
||||
namespace_c,
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
),
|
||||
['a'],
|
||||
namespace_a,
|
||||
),
|
||||
['a'],
|
||||
namespace_a,
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'name',
|
||||
[namespace_a, namespace_c],
|
||||
),
|
||||
['a', 'b'],
|
||||
namespace_b,
|
||||
),
|
||||
['a', 'b'],
|
||||
namespace_b,
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i'],
|
||||
namespace_i,
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i', 'j'],
|
||||
namespace_j,
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i', 'j', 'k'],
|
||||
namespace_k,
|
||||
),
|
||||
])
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i'],
|
||||
namespace_i,
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i', 'j'],
|
||||
namespace_j,
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
['e', 'f', 'g', 'h', 'i', 'j', 'k'],
|
||||
namespace_k,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace_namespace(
|
||||
namespace: PythonPackageNamespace,
|
||||
sub_namespaces,
|
||||
@@ -112,6 +125,7 @@ def test_PythonPackageNamespace_namespace(
|
||||
):
|
||||
assert namespace.namespace(sub_namespaces) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,sub_namespaces,expected_exception,expected_exception_msg',
|
||||
[
|
||||
@@ -157,129 +171,145 @@ def test_PythonPackageNamespace_namespace_exceptions(
|
||||
namespace.namespace(sub_namespaces)
|
||||
assert str(exc_info.value) == expected_exception_msg
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected', [
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected',
|
||||
[
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
),
|
||||
{'b': 'b'},
|
||||
),
|
||||
{'b': 'b'},
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
),
|
||||
{
|
||||
'b': 'b',
|
||||
'c': {'d': 'd'},
|
||||
},
|
||||
),
|
||||
{
|
||||
'b': 'b',
|
||||
'c': {'d': 'd'},
|
||||
},
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
{},
|
||||
),
|
||||
])
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
{},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
||||
assert namespace.sub_namespace_names() == expected
|
||||
|
||||
@pytest.mark.parametrize('namespace1,namespace2,expected', [
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace1,namespace2,expected',
|
||||
[
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
),
|
||||
True,
|
||||
),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
),
|
||||
True,
|
||||
),
|
||||
True,
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonPackageNamespace('a', []),
|
||||
True,
|
||||
),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'c',
|
||||
[PythonModuleNamespace('d')],
|
||||
),
|
||||
],
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonPackageNamespace('b', []),
|
||||
False,
|
||||
),
|
||||
True,
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonPackageNamespace('a', []),
|
||||
True,
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonPackageNamespace('b', []),
|
||||
False,
|
||||
),
|
||||
])
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
|
||||
assert (namespace1 == namespace2) == expected
|
||||
assert (namespace2 == namespace1) == expected
|
||||
|
||||
@pytest.mark.parametrize('namespace,expected', [
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
'PythonPackageNamespace(\'a\', [])',
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace('1', []),
|
||||
'PythonPackageNamespace(\'1\', [])',
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(StrSubclass('a'), []),
|
||||
'PythonPackageNamespace(\'a\', [])',
|
||||
),
|
||||
(
|
||||
namespace_a,
|
||||
'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])',
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,expected',
|
||||
[
|
||||
(
|
||||
'PythonPackageNamespace(\'d\', [PythonPackageNamespac'
|
||||
'e(\'e\', [PythonPackageNamespace(\'f\', [PythonPacka'
|
||||
'geNamespace(\'g\', [PythonPackageNamespace(\'h\', [P'
|
||||
'ythonPackageNamespace(\'i\', [PythonPackageNamespace'
|
||||
'(\'j\', [PythonModuleNamespace(\'k\')])])])])])])])'
|
||||
PythonPackageNamespace('a', []),
|
||||
"PythonPackageNamespace('a', [])",
|
||||
),
|
||||
),
|
||||
])
|
||||
(
|
||||
PythonPackageNamespace('1', []),
|
||||
"PythonPackageNamespace('1', [])",
|
||||
),
|
||||
(
|
||||
PythonPackageNamespace(StrSubclass('a'), []),
|
||||
"PythonPackageNamespace('a', [])",
|
||||
),
|
||||
(
|
||||
namespace_a,
|
||||
"PythonPackageNamespace('a', [PythonModuleNamespace('b')])",
|
||||
),
|
||||
(
|
||||
namespace_d,
|
||||
(
|
||||
"PythonPackageNamespace('d', [PythonPackageNamespac"
|
||||
"e('e', [PythonPackageNamespace('f', [PythonPacka"
|
||||
"geNamespace('g', [PythonPackageNamespace('h', [P"
|
||||
"ythonPackageNamespace('i', [PythonPackageNamespace"
|
||||
"('j', [PythonModuleNamespace('k')])])])])])])])"
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace_string_representation(namespace, expected):
|
||||
assert repr(namespace) == expected
|
||||
|
||||
@pytest.mark.parametrize('namespace,new_namespace,expected', [
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'namespace,new_namespace,expected',
|
||||
[
|
||||
(
|
||||
PythonPackageNamespace('a', []),
|
||||
PythonModuleNamespace('b'),
|
||||
PythonPackageNamespace(
|
||||
'a',
|
||||
[PythonModuleNamespace('b')],
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
],
|
||||
)
|
||||
def test_PythonPackageNamespace___getitem__(
|
||||
namespace,
|
||||
new_namespace,
|
||||
|
||||
Reference in new issue
Block a user