style: ensure trailing commas in multi-line statements

This commit is contained in:
jakob.scheid committed 2026-09-18 22:18:13 +02:00
1 parent ffcc7404de
commit 475775eb7e
30 files changed
+1778 -1774

No files matched your search

+2 -2
View File
@@ -21,10 +21,10 @@ def test_cli():
sys.executable,
'-m',
'jcloud_docsgen',
'--help'
'--help',
],
capture_output = True,
text = True
text = True,
)
stdout = result.stdout.lower()
assert \
+2 -2
View File
@@ -18,7 +18,7 @@ from jcloud_docsgen.cli.cli import create_argument_parser
@pytest.mark.parametrize('lang', [
'javascript',
'Python',
'PYTHON'
'PYTHON',
])
def test_language_error(lang):
parser = create_argument_parser()
@@ -27,7 +27,7 @@ def test_language_error(lang):
parser.parse_args([lang])
@pytest.mark.parametrize('lang', [
'python'
'python',
])
def test_language_success(lang):
parser = create_argument_parser()
+18 -18
View File
@@ -33,8 +33,8 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = False,
decorators = False,
class_body = False
)
class_body = False,
),
),
(
[],
@@ -48,8 +48,8 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = False,
decorators = False,
class_body = False
)
class_body = False,
),
),
(
['signature'],
@@ -63,8 +63,8 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = False,
decorators = False,
class_body = False
)
class_body = False,
),
),
(
['signature'],
@@ -78,13 +78,13 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = False,
decorators = False,
class_body = False
)
class_body = False,
),
),
(
None,
[],
PythonDefinitionDocumentationIncludeSections()
PythonDefinitionDocumentationIncludeSections(),
),
(
['signature', 'exceptions', 'bases', 'class_body'],
@@ -98,8 +98,8 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = False,
decorators = False,
class_body = True
)
class_body = True,
),
),
(
None,
@@ -113,8 +113,8 @@ from jcloud_docsgen.core.python import (
docstring = False,
bases = True,
decorators = True,
class_body = True
)
class_body = True,
),
)
])
def test_parse_sections_list(include, exclude, expected):
@@ -127,7 +127,7 @@ def test_sections_error():
parser.parse_args([
'python',
'-s',
'param' # correct: `params`
'param', # correct: `params`
])
with pytest.raises(SystemExit):
@@ -135,7 +135,7 @@ def test_sections_error():
'python',
'-s',
'params',
'docstrng' # correct: `docstring`
'docstrng', # correct: `docstring`
])
def test_sections_success():
@@ -144,13 +144,13 @@ def test_sections_success():
parser.parse_args([
'python',
'-s',
'params'
'params',
])
parser.parse_args([
'python',
'-s',
'params',
'docstring'
'docstring',
])
def test_docs_generation(expectdir):
@@ -164,5 +164,5 @@ def test_docs_generation(expectdir):
'docstring',
'-HTo',
str(output_dir),
str(input_dir)
str(input_dir),
])
File diff suppressed because it is too large. Load diff
@@ -15,7 +15,7 @@
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
from src.jcloud_docsgen.core.python.namespaces import (
PythonModuleNamespace,
PythonPackageNamespace
PythonPackageNamespace,
)
import pytest
import pathlib
@@ -28,9 +28,9 @@ import pathlib
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_1/docs'
)
),
),
[]
[],
),
(
PythonDocumentationGenerator(
@@ -39,16 +39,16 @@ import pathlib
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_2/docs'
)
),
),
[
PythonPackageNamespace(
'pkg',
[
PythonModuleNamespace('module')
]
)
]
],
),
],
),
(
PythonDocumentationGenerator(
@@ -57,7 +57,7 @@ import pathlib
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_3/docs'
)
),
),
[
PythonPackageNamespace(
@@ -69,17 +69,17 @@ import pathlib
[
PythonModuleNamespace(
'module2'
)
]
)
]
)
]
),
],
),
],
),
],
),
])
def test_PythonDocumentationGenerator_collect_modules(
python_documentation_generator: PythonDocumentationGenerator,
expected
expected,
):
assert python_documentation_generator.namespace() == expected
@@ -89,7 +89,7 @@ def test_PythonDocumentationGenerator_collect_modules(
(
'tests/unit/core/python/_core/test_PythonDocume'
'ntationGenerator/test_generate_documentation/'
)
),
).iterdir()
])
def test_generate_documentation(dir, expectdir):
@@ -103,13 +103,13 @@ def test_generate_documentation(dir, expectdir):
(
'tests/unit/core/python/_core/test_PythonDocume'
'ntationGenerator/test_generate_documentation/'
)
),
) /
dir /
'project'
)
'project',
),
),
pathlib.Path(str(d)),
allow_tables = True,
allow_html = False
allow_html = False,
).generate_documentation() # simplify the tests
@@ -25,194 +25,192 @@ import pytest
(
'tests/unit/core/python/_core/fil'
'es_with_more_than_one_dot/a.b.c'
)
),
),
None,
InvalidNamespaceError,
'namespace identifier cannot contain more than one dot: a.b.c'
'namespace identifier cannot contain more than one dot: a.b.c',
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/file'
's_with_more_than_one_dot/a.b.c.d'
)
),
),
None,
InvalidNamespaceError,
'namespace identifier cannot contain more than one dot: a.b.c.d'
'namespace identifier cannot contain more than one dot: a.b.c.d',
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files'
'_with_more_than_one_dot/a.b.c.d.e'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot cont'
'ain more than one dot: a.b.c.d.e'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_'
'with_more_than_one_dot/a.b.c.d.e.f'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot conta'
'in more than one dot: a.b.c.d.e.f'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_w'
'ith_more_than_one_dot/a.b.c.d.e.f.g'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contai'
'n more than one dot: a.b.c.d.e.f.g'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_wi'
'th_more_than_one_dot/a.b.c.d.e.f.g.h'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contain'
' more than one dot: a.b.c.d.e.f.g.h'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_wit'
'h_more_than_one_dot/a.b.c.d.e.f.g.h.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contain m'
'ore than one dot: a.b.c.d.e.f.g.h.py'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_wi'
'th_more_than_one_dot/a.b.c.d.e.f.g.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contain '
'more than one dot: a.b.c.d.e.f.g.py'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_w'
'ith_more_than_one_dot/a.b.c.d.e.f.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contain'
' more than one dot: a.b.c.d.e.f.py'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files_'
'with_more_than_one_dot/a.b.c.d.e.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot contai'
'n more than one dot: a.b.c.d.e.py'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/files'
'_with_more_than_one_dot/a.b.c.d.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot conta'
'in more than one dot: a.b.c.d.py'
)
),
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/file'
's_with_more_than_one_dot/a.b.c.py'
)
),
),
None,
InvalidNamespaceError,
(
'namespace identifier cannot cont'
'ain more than one dot: a.b.c.py'
)
),
),
(
pathlib.Path(
(
(
'tests/unit/core/python/_core/fil'
'es_with_more_than_one_dot/a.b.py'
)
)
'tests/unit/core/python/_core/fil'
'es_with_more_than_one_dot/a.b.py'
),
),
None,
InvalidNamespaceError,
'namespace identifier cannot contain more than one dot: a.b.py'
'namespace identifier cannot contain more than one dot: a.b.py',
),
(
pathlib.Path(
(
'tests/unit/core/python/_core/direc'
'tory.with.more.than.one.dot/a.b.py'
)
),
),
None,
InvalidNamespaceError,
'namespace identifier cannot contain more than one dot: a.b.py'
'namespace identifier cannot contain more than one dot: a.b.py',
),
]
],
)
def test_PythonModuleDocumentationGenerator_exceptions(
module_path,
src_directory,
expected_exception,
expected_exception_msg
expected_exception_msg,
):
with pytest.raises(expected_exception) as exc_info:
PythonModuleDocumentationGenerator(module_path, src_directory)
@@ -225,13 +223,13 @@ def test_PythonModuleDocumentationGenerator_exceptions(
(
'tests/unit/core/python/_core/test_pr'
'oject_dirs/pdir_2/src/pkg/module.py'
)
),
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_2/src/'
),
allow_tables = True,
allow_html = False
allow_html = False,
),
'''# Module `pkg.module`
@@ -409,11 +407,11 @@ A dog.'''
(
'tests/unit/core/python/_core/test_pr'
'oject_dirs/pdir_2/src/pkg/module.py'
)
),
),
None,
allow_tables = True,
allow_html = False
allow_html = False,
),
'''# Module `module`
@@ -591,11 +589,11 @@ A dog.'''
(
'tests/unit/core/python/_core/test_pr'
'oject_dirs/pdir_2/src/pkg/module.py'
)
),
),
None,
allow_tables = True,
allow_html = True
allow_html = True,
),
(
'''# Module `module`
@@ -761,7 +759,7 @@ Return type: `None`
<details><summary><h3 style="display:inline">Docstring</h3></summary>A dog.'''
'</details>'
)
),
),
(
@@ -770,11 +768,11 @@ Return type: `None`
(
'tests/unit/core/python/_core/test_pr'
'oject_dirs/pdir_2/src/pkg/module.py'
)
),
),
None,
allow_tables = False,
allow_html = True
allow_html = True,
),
(
'''# Module `module`
@@ -982,7 +980,7 @@ Return type: `None`
<details><summary><h3 style="display:inline">Docstring</h3></summary>A '''
'dog.</details>'
)
),
),
(
@@ -991,11 +989,11 @@ Return type: `None`
(
'tests/unit/core/python/_core/test_pr'
'oject_dirs/pdir_2/src/pkg/module.py'
)
),
),
None,
allow_tables = False,
allow_html = False
allow_html = False,
),
'''# Module `module`
@@ -1211,6 +1209,6 @@ A dog.'''
])
def test_PythonModuleDocumentationGenerator_exceptions(
module_documentation_generator,
expected
expected,
):
assert module_documentation_generator.generate_documentation() == expected
@@ -15,11 +15,11 @@
from src.jcloud_docsgen.core.python._core import _collect_definitions
from src.jcloud_docsgen.core.python.definitions import (
PythonClassDefinition,
PythonFunctionDefinition
PythonFunctionDefinition,
)
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
import pytest
@@ -49,20 +49,20 @@ def module(source_code: str) -> ast.Module:
'a',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
None
None,
),
],
None,
None,
[]
)
]
[],
),
],
),
(
module('''def add(a: int | float, b: int | float) -> int | float:
@@ -97,18 +97,18 @@ class Something:
'a',
PythonArgumentKind.NORMAL,
None,
'int | float'
'int | float',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int | float'
'int | float',
),
],
'int | float',
PythonDocstring('Adds two numbers.'),
[]
[],
),
PythonClassDefinition(
'Something',
@@ -123,18 +123,18 @@ class Something:
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'value',
PythonArgumentKind.NORMAL,
'42',
'typing.Any'
'typing.Any',
),
],
'None',
None,
[]
[],
),
PythonFunctionDefinition(
'value',
@@ -143,12 +143,12 @@ class Something:
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
),
],
'typing.Any',
PythonDocstring('The value.'),
['property']
['property'],
),
PythonFunctionDefinition(
'get_value',
@@ -157,16 +157,16 @@ class Something:
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
),
],
'typing.Any',
PythonDocstring('Returns the value.'),
[]
[],
),
]
)
]
],
),
],
),
(
module('''from src.jcloud_docsgen.core.python import (
@@ -244,13 +244,13 @@ def test_PythonDocumentationGenerator_collect_modules(
'project_directory',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'docs_directory',
PythonArgumentKind.NORMAL,
None,
None
None,
)
],
None,
@@ -263,8 +263,8 @@ def test_PythonDocumentationGenerator_collect_modules(
'''(pathlib.Path('tests/'), 1), (1, pathlib'''
'''.Path('tests/')), (1, pathlib.Path('test'''
'''s')), (None, pathlib.Path('tests'))])'''
)
]
),
],
),
PythonFunctionDefinition(
'test_PythonDocumentationGenerator_collect_modules',
@@ -273,13 +273,13 @@ def test_PythonDocumentationGenerator_collect_modules(
'python_documentation_generator',
PythonArgumentKind.NORMAL,
None,
'PythonDocumentationGenerator'
'PythonDocumentationGenerator',
),
PythonFunctionArgument(
'expected',
PythonArgumentKind.NORMAL,
None,
None
None,
)
],
None,
@@ -301,9 +301,9 @@ def test_PythonDocumentationGenerator_collect_modules(
'''r_3/docs')), [PythonPackageNamespace('pkg', [Python'''
'''ModuleNamespace(\'module'), PythonPackageNamespace('''
'''\'pkg\', [PythonModuleNamespace(\'module2')])])])])'''
)]
)
]
)],
),
],
),
(
module(
@@ -341,33 +341,33 @@ def test_PythonDocumentationGenerator_collect_modules(
'self',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'value',
PythonArgumentKind.POSITIONAL_ONLY,
None,
'bool'
'bool',
),
PythonFunctionArgument(
'arg',
PythonArgumentKind.NORMAL,
None,
None
None,
)
],
'bool',
None,
[]
)
]
)
]
)
]
)
]
)
[],
),
],
),
],
),
],
),
],
),
])
def test___collect_definitions(module, expected):
assert list(_collect_definitions(module)) == expected
@@ -14,17 +14,17 @@
from src.jcloud_docsgen.core.python._core import (
_function_params_info,
_FunctionParamInfo
_FunctionParamInfo,
)
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
import pytest
import docstring_parser
def docstring_args_list(
docstring: str
docstring: str,
) -> list[docstring_parser.DocstringParam]:
'''
Returns the parameter list of a docstring.
@@ -42,68 +42,68 @@ def docstring_args_list(
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'int'),
], ':param a: a\n:type a: str', {
'a': _FunctionParamInfo('int', 'a')
'a': _FunctionParamInfo('int', 'a'),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
], ':param a: a\n:type a: str', {
'a': _FunctionParamInfo('str', 'a')
'a': _FunctionParamInfo('str', 'a'),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', None),
], ':param a: a\n:type a: str', {
'a': _FunctionParamInfo('str', 'a'),
'b': _FunctionParamInfo(None, None)
'b': _FunctionParamInfo(None, None),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
], ':param a: a\n:type a: str', {
'a': _FunctionParamInfo('str', 'a'),
'b': _FunctionParamInfo('int', None)
'b': _FunctionParamInfo('int', None),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
], ':param a: a\n:type a: str\n:param b: b\n:type b: str', {
'a': _FunctionParamInfo('str', 'a'),
'b': _FunctionParamInfo('int', 'b')
'b': _FunctionParamInfo('int', 'b'),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
], ':param a: a\n:type a: str\n:param b: b\n:type b: int', {
'a': _FunctionParamInfo('str', 'a')
'a': _FunctionParamInfo('str', 'a'),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
], '', {
'a': _FunctionParamInfo(None, None)
'a': _FunctionParamInfo(None, None),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
], '', {
'a': _FunctionParamInfo('str', None)
'a': _FunctionParamInfo('str', None),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
], ':param a:\n:type a: int', {
'a': _FunctionParamInfo('str', '')
'a': _FunctionParamInfo('str', ''),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
], ':param a:\n:type a: int', {
'a': _FunctionParamInfo('int', '')
'a': _FunctionParamInfo('int', ''),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
], ':param a: a', {
'a': _FunctionParamInfo(None, 'a')
'a': _FunctionParamInfo(None, 'a'),
}),
([
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
], ':param a: a', {
'a': _FunctionParamInfo('str', 'a')
'a': _FunctionParamInfo('str', 'a'),
}),
([], ':param a: a\n:type a: str', {}),
([], '', {}),
@@ -28,7 +28,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
[],
@@ -37,7 +37,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
['a'],
@@ -46,7 +46,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
['a'],
@@ -57,7 +57,7 @@ import pytest
'--',
'''| a |
| --- |
| 1 |'''
| 1 |''',
),
(
['a'],
@@ -68,7 +68,7 @@ import pytest
'--',
'''| a |
| --- |
| 1 |'''
| 1 |''',
),
(
['a', 'b'],
@@ -79,7 +79,7 @@ import pytest
'--',
'''| a | b |
| --- | --- |
| 1 | 2 |'''
| 1 | 2 |''',
),
(
['a', 'b'],
@@ -90,7 +90,7 @@ import pytest
'--',
'''| a | b |
| --- | --- |
| 1 | -- |'''
| 1 | -- |''',
),
(
['a', 'b'],
@@ -101,7 +101,7 @@ import pytest
'--',
'''| a | b |
| --- | --- |
| -- | -- |'''
| -- | -- |''',
),
(
['a', 'b'],
@@ -113,7 +113,7 @@ import pytest
'''| a | b |
| --- | --- |
| 1 | 2 |
| 3 | 4 |'''
| 3 | 4 |''',
),
(
['a'],
@@ -124,7 +124,7 @@ import pytest
'--',
'''| a |
| --- |
| line1 line2 |'''
| line1 line2 |''',
),
(
['a'],
@@ -135,7 +135,7 @@ import pytest
'--',
'''| a |
| --- |
| line1\nline2 |'''
| line1\nline2 |''',
),
(
@@ -145,7 +145,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
[],
@@ -154,7 +154,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
['a'],
@@ -163,7 +163,7 @@ import pytest
False,
True,
'--',
''
'',
),
(
['a'],
@@ -172,7 +172,7 @@ import pytest
False,
True,
'--',
'- a: 1'
'- a: 1',
),
(
['a'],
@@ -181,7 +181,7 @@ import pytest
False,
True,
'--',
'- a: 1'
'- a: 1',
),
(
['a', 'b'],
@@ -192,7 +192,7 @@ import pytest
'--',
'''- a: 1
b: 2'''
b: 2''',
),
(
['a', 'b'],
@@ -203,7 +203,7 @@ import pytest
'--',
'''- a: 1
b: --'''
b: --''',
),
(
['a', 'b'],
@@ -214,7 +214,7 @@ import pytest
'--',
'''- a: --
b: --'''
b: --''',
),
(
['a', 'b'],
@@ -229,7 +229,7 @@ import pytest
- a: 3
b: 4'''
b: 4''',
),
(
['a'],
@@ -238,7 +238,7 @@ import pytest
False,
True,
'--',
'- a: line1 line2'
'- a: line1 line2',
),
(
['a'],
@@ -247,9 +247,9 @@ import pytest
False,
False,
'--',
'- a: line1\nline2'
)
]
'- a: line1\nline2',
),
],
)
def test__markdown_table(
header,
@@ -258,7 +258,7 @@ def test__markdown_table(
force_row_lengths,
one_line_values,
missing_value,
expected
expected,
):
assert _markdown_table(
header,
@@ -266,7 +266,7 @@ def test__markdown_table(
allow_markdown_table = allow_markdown_table,
force_row_lengths = force_row_lengths,
one_line_values = one_line_values,
missing_value = missing_value
missing_value = missing_value,
) == expected
@pytest.mark.parametrize(
@@ -283,7 +283,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 2'
'expected 1 value, got 2',
),
(
['a'],
@@ -293,7 +293,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 3'
'expected 1 value, got 3',
),
(
['a'],
@@ -303,7 +303,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 0'
'expected 1 value, got 0',
),
(
['a', 'b'],
@@ -313,7 +313,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 0'
'expected 2 values, got 0',
),
(
['a', 'b'],
@@ -323,7 +323,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 1'
'expected 2 values, got 1',
),
(
['a', 'b'],
@@ -333,7 +333,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 3'
'expected 2 values, got 3',
),
(
@@ -344,7 +344,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 2'
'expected 1 value, got 2',
),
(
['a'],
@@ -354,7 +354,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 3'
'expected 1 value, got 3',
),
(
['a'],
@@ -364,7 +364,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 1 value, got 0'
'expected 1 value, got 0',
),
(
['a', 'b'],
@@ -374,7 +374,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 0'
'expected 2 values, got 0',
),
(
['a', 'b'],
@@ -384,7 +384,7 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 1'
'expected 2 values, got 1',
),
(
['a', 'b'],
@@ -394,9 +394,9 @@ def test__markdown_table(
True,
'--',
ValueError,
'expected 2 values, got 3'
)
]
'expected 2 values, got 3',
),
],
)
def test__markdown_table_exceptions(
header,
@@ -406,7 +406,7 @@ def test__markdown_table_exceptions(
one_line_values,
missing_value,
expected_exception,
expected_exception_msg
expected_exception_msg,
):
with pytest.raises(expected_exception) as exc_info:
_markdown_table(
@@ -415,6 +415,6 @@ def test__markdown_table_exceptions(
allow_markdown_table = allow_markdown_table,
force_row_lengths = force_row_lengths,
one_line_values = one_line_values,
missing_value = missing_value
missing_value = missing_value,
)
assert str(exc_info.value) == expected_exception_msg
@@ -15,7 +15,7 @@
from src.jcloud_docsgen.core.python._core import _signature_argument_list
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
import pytest
@@ -25,93 +25,93 @@ import pytest
'a',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
], ['a']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
)
None,
),
], ['a', '/']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
], ['a', '/', 'b']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'c',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
)
None,
),
], ['a', '/', 'b', '*', 'c']),
([
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'c',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
)
None,
),
], ['b', '*', 'c']),
([
PythonFunctionArgument(
'c',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
)
None,
),
], ['*', 'c']),
([
PythonFunctionArgument(
'b',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'c',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
)
None,
),
], ['b', '/', '*', 'c']),
([
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
)
], ['*args']),
([
@@ -119,164 +119,164 @@ import pytest
'a',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
)
None,
),
], ['a', '*args']),
([
PythonFunctionArgument(
'a', PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
)
None,
),
], ['a', '/', '*args']),
([
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
),
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
)
None,
),
], ['*args', 'a']),
([
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['*args', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['a', '/', '*args', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['a', '*args', '**kwargs']),
([
PythonFunctionArgument(
'args',
PythonArgumentKind.VARARG,
None,
None
None,
),
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['*args', 'a', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['*', 'a', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['a', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
PythonFunctionArgument(
'kwargs',
PythonArgumentKind.KWARGS,
None,
None
)
None,
),
], ['a', '/', '**kwargs']),
([
PythonFunctionArgument(
'a',
PythonArgumentKind.NORMAL,
'1',
'int'
'int',
),
], ['a: int = 1']),
])
File diff suppressed because it is too large. Load diff
@@ -14,12 +14,12 @@
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.exceptions import (
InvalidPythonIdentifierError,
InvalidPythonAnnotationError,
PythonArgumentStructureError
PythonArgumentStructureError,
)
import pytest
@@ -32,7 +32,7 @@ import pytest
None,
None,
TypeError,
'expected \'str\', got \'NoneType\''
'expected \'str\', got \'NoneType\'',
),
(
1,
@@ -40,7 +40,7 @@ import pytest
None,
None,
TypeError,
'expected \'str\', got \'int\''
'expected \'str\', got \'int\'',
),
(
42,
@@ -48,7 +48,7 @@ import pytest
None,
None,
TypeError,
'expected \'str\', got \'int\''
'expected \'str\', got \'int\'',
),
(
4.2,
@@ -56,7 +56,7 @@ import pytest
None,
None,
TypeError,
'expected \'str\', got \'float\''
'expected \'str\', got \'float\'',
),
(
4.2,
@@ -64,7 +64,7 @@ import pytest
None,
None,
TypeError,
'expected \'str\', got \'float\''
'expected \'str\', got \'float\'',
),
(
'a',
@@ -72,7 +72,7 @@ import pytest
1,
None,
TypeError,
'expected either \'str\' or \'NoneType\', got \'int\''
'expected either \'str\' or \'NoneType\', got \'int\'',
),
(
'a',
@@ -80,7 +80,7 @@ import pytest
None,
1,
TypeError,
'expected either \'str\' or \'NoneType\', got \'int\''
'expected either \'str\' or \'NoneType\', got \'int\'',
),
(
'a',
@@ -88,7 +88,7 @@ import pytest
None,
None,
TypeError,
'expected \'PythonArgumentKind\', got \'int\''
'expected \'PythonArgumentKind\', got \'int\'',
),
(
'a',
@@ -96,7 +96,7 @@ import pytest
None,
'',
InvalidPythonAnnotationError,
'invalid annotation'
'invalid annotation',
),
(
'',
@@ -104,7 +104,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
@@ -112,7 +112,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
@@ -120,7 +120,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
@@ -128,7 +128,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
@@ -136,7 +136,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
@@ -144,7 +144,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
@@ -152,7 +152,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
@@ -160,7 +160,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
@@ -168,7 +168,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
@@ -176,7 +176,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
@@ -184,7 +184,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
@@ -192,7 +192,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
@@ -200,7 +200,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
@@ -208,7 +208,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
@@ -216,7 +216,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
@@ -224,7 +224,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
@@ -232,7 +232,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
@@ -240,7 +240,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
@@ -248,7 +248,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
@@ -256,7 +256,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
@@ -264,7 +264,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
@@ -272,7 +272,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
@@ -280,7 +280,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
@@ -288,7 +288,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
@@ -296,7 +296,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
@@ -304,7 +304,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
@@ -312,7 +312,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
@@ -320,7 +320,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
@@ -328,7 +328,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
@@ -336,7 +336,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
@@ -344,7 +344,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
@@ -352,7 +352,7 @@ import pytest
None,
None,
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
(
'a',
@@ -360,7 +360,7 @@ import pytest
'1',
None,
PythonArgumentStructureError,
'* or ** arguments cannot have default values: *a = 1'
'* or ** arguments cannot have default values: *a = 1',
),
(
'a',
@@ -368,9 +368,9 @@ import pytest
'1',
None,
PythonArgumentStructureError,
'* or ** arguments cannot have default values: **a = 1'
'* or ** arguments cannot have default values: **a = 1',
),
]
],
)
def test_PythonFunctionArgument_exceptions(
name,
@@ -378,7 +378,7 @@ def test_PythonFunctionArgument_exceptions(
default,
annotation,
expected_exception,
expected_exception_msg
expected_exception_msg,
):
with pytest.raises(expected_exception) as exc_info:
PythonFunctionArgument(name, kind, default, annotation)
@@ -459,18 +459,18 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation):
'a',
PythonArgumentKind.NORMAL,
None,
None
None,
),
'a'
'a',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.NORMAL,
'1',
None
None,
),
'a = 1'
'a = 1',
),
(
PythonFunctionArgument(
@@ -479,124 +479,124 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation):
None,
'int'
),
'a: int'
'a: int',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.NORMAL,
'1',
'int'
'int',
),
'a: int = 1'
'a: int = 1',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
None
None,
),
'a'
'a',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
'1',
None
None,
),
'a = 1'
'a = 1',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
None,
'int'
'int',
),
'a: int'
'a: int',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.POSITIONAL_ONLY,
'1',
'int'
'int',
),
'a: int = 1'
'a: int = 1',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
None,
None
None,
),
'a'
'a',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
'1',
None
None,
),
'a = 1'
'a = 1',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
None,
'int'
'int',
),
'a: int'
'a: int',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KEYWORD_ONLY,
'1',
'int'
'int',
),
'a: int = 1'
'a: int = 1',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.VARARG,
None,
None
None,
),
'*a'
'*a',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.VARARG,
None,
'int'
'int',
),
'*a: int'
'*a: int',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KWARGS,
None,
None
None,
),
'**a'
'**a',
),
(
PythonFunctionArgument(
'a',
PythonArgumentKind.KWARGS,
None,
'int'
'int',
),
'**a: int'
'**a: int',
),
])
def test_PythonFunctionArgument_signature_repr(argument, expected):
@@ -14,11 +14,11 @@
from src.jcloud_docsgen.core.python.definitions import (
PythonFunctionDefinition,
PythonClassDefinition
PythonClassDefinition,
)
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
@@ -32,9 +32,9 @@ import pytest
[],
None,
None,
[]
[],
),
'PythonClassDefinition(\'A\', [], None, None, [])'
'PythonClassDefinition(\'A\', [], None, None, [])',
),
(
PythonClassDefinition(
@@ -42,12 +42,12 @@ import pytest
[],
None,
PythonDocstring('Hello, World!'),
[]
[],
),
(
'PythonClassDefinition(\'A\', [], None, '
'PythonDocstring(\'Hello, World!\'), [])'
)
),
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -67,7 +67,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
@@ -76,7 +76,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
@@ -85,7 +85,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
@@ -94,7 +94,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
@@ -103,7 +103,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
@@ -112,7 +112,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
@@ -121,7 +121,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
@@ -130,7 +130,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
@@ -139,7 +139,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
@@ -148,7 +148,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
@@ -157,7 +157,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
@@ -166,7 +166,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
@@ -175,7 +175,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
@@ -184,7 +184,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
@@ -193,7 +193,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
@@ -202,7 +202,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
@@ -211,7 +211,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
@@ -220,7 +220,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
@@ -229,7 +229,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
@@ -238,7 +238,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
@@ -247,7 +247,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
@@ -256,7 +256,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
@@ -265,7 +265,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
@@ -274,7 +274,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
@@ -283,7 +283,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
@@ -292,7 +292,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
@@ -301,7 +301,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
@@ -310,7 +310,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
@@ -319,7 +319,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
@@ -328,7 +328,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
@@ -337,7 +337,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
@@ -346,9 +346,9 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
]
],
)
def test_PythonFunctionDefinition_exceptions(
name,
@@ -357,7 +357,7 @@ def test_PythonFunctionDefinition_exceptions(
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonClassDefinition(name, args, returns, doc, decorators)
@@ -372,8 +372,7 @@ def test_PythonFunctionDefinition_exceptions(
':\n\tdef __init__(self, value: object) -> None:'
'\n\t\tself._value = value\n\n\t@property\n\tdef'
' value(self) -> object:\n\t\treturn self._value'
)
),
),
PythonClassDefinition(
'Class',
@@ -388,18 +387,18 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'value',
PythonArgumentKind.NORMAL,
None,
'object'
)
'object',
),
],
'None',
None,
[]
[],
),
PythonFunctionDefinition(
'value',
@@ -408,15 +407,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
],
'object',
None,
['property']
)
]
)
['property'],
),
],
),
),
(
ast_node('class Class: ...'),
@@ -425,8 +424,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
[],
[]
)
[],
),
),
(
ast_node('class Class: \'\'\'docstring\'\'\''),
@@ -435,8 +434,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
PythonDocstring('docstring'),
[],
[]
)
[],
),
),
(
ast_node('class Class:\n\tdef __init__(self): ...'),
@@ -453,15 +452,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
)
],
None,
None,
[]
)
]
)
[],
),
],
),
),
(
ast_node('class Class:\n\t\'\'\'doc\'\'\'\n\tdef __init__(self): ...'),
@@ -478,15 +477,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
],
None,
None,
[]
)
]
)
[],
),
],
),
),
])
def test_PythonDefinition_from_node(node, expected):
@@ -22,17 +22,17 @@ import pytest
PythonDefinition(
'a',
None,
[]
[],
),
'PythonDefinition(\'a\', None, [])'
'PythonDefinition(\'a\', None, [])',
),
(
PythonDefinition(
'a',
PythonDocstring('Hello, World!'),
[]
[],
),
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])'
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])',
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -47,233 +47,233 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
]
],
)
def test_PythonDefinition_exceptions(
name,
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonDefinition(name, doc, decorators)
@@ -285,157 +285,157 @@ def test_PythonDefinition_exceptions(
PythonDefinition(
'a',
None,
[]
[],
),
PythonDefinition(
'a',
None,
[]
[],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
['a']
['a'],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
['a']
['a'],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
['a', 'b']
['a', 'b'],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
['a', 'b']
['a', 'b'],
),
True
True,
),
(
PythonDefinition(
'a',
None,
[]
[],
),
PythonDefinition(
'b',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
PythonDocstring('docs'),
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
['b']
['b'],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['b', 'a']
['b', 'a'],
),
PythonDefinition(
'a',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'b',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
])
def test_PythonDefinition___eq__(definition1, definition2, expected):
@@ -15,7 +15,7 @@
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
@@ -29,9 +29,9 @@ import pytest
[],
None,
None,
[]
[],
),
'PythonFunctionDefinition(\'a\', [], None, None, [])'
'PythonFunctionDefinition(\'a\', [], None, None, [])',
),
(
PythonFunctionDefinition(
@@ -39,12 +39,12 @@ import pytest
[],
None,
PythonDocstring('Hello, World!'),
[]
[],
),
(
'PythonFunctionDefinition(\'a\', [], None,'
' PythonDocstring(\'Hello, World!\'), [])'
)
),
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -64,7 +64,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
@@ -73,7 +73,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
@@ -82,7 +82,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
@@ -91,7 +91,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
@@ -100,7 +100,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
@@ -109,7 +109,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
@@ -118,7 +118,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
@@ -127,7 +127,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
@@ -136,7 +136,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
@@ -145,7 +145,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
@@ -154,7 +154,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
@@ -163,7 +163,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
@@ -172,7 +172,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
@@ -181,7 +181,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
@@ -190,7 +190,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
@@ -199,7 +199,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
@@ -208,7 +208,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
@@ -217,7 +217,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
@@ -226,7 +226,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
@@ -235,7 +235,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
@@ -244,7 +244,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
@@ -253,7 +253,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
@@ -262,7 +262,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
@@ -271,7 +271,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
@@ -280,7 +280,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
@@ -289,7 +289,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
@@ -298,7 +298,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
@@ -307,7 +307,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
@@ -316,7 +316,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
@@ -325,7 +325,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
@@ -334,7 +334,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
@@ -343,7 +343,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
])
def test_PythonFunctionDefinition_exceptions(
@@ -353,7 +353,7 @@ def test_PythonFunctionDefinition_exceptions(
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonFunctionDefinition(name, args, returns, doc, decorators)
@@ -369,19 +369,19 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
[]
)
[],
),
),
(
ast_node('@decorator\ndef add(a: int, b: int) -> int: return a + b'),
@@ -392,26 +392,26 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
['decorator']
)
['decorator'],
),
),
(
ast_node(
(
'@decorator1\n@decorator2\ndef add(a'
': int, b: int) -> int: return a + b'
)
),
),
PythonFunctionDefinition(
'add',
@@ -420,19 +420,19 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
['decorator1', 'decorator2']
)
['decorator1', 'decorator2'],
),
),
(
ast_node('def func(): ...'),
@@ -441,8 +441,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
None,
[]
)
[],
),
),
(
ast_node('@decorator\ndef func(): ...'),
@@ -451,8 +451,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
None,
['decorator']
)
['decorator'],
),
),
])
def test_PythonDefinition_from_node(node, expected):
@@ -14,12 +14,12 @@
from src.jcloud_docsgen.core.python.namespaces import (
PythonPackageNamespace,
PythonModuleNamespace
PythonModuleNamespace,
)
import pytest
from src.jcloud_docsgen.exceptions import (
NamespaceNotFoundError,
InvalidNamespaceError
InvalidNamespaceError,
)
class StrSubclass(str): ...
@@ -28,23 +28,23 @@ class StrSubclass(str): ...
(
PythonPackageNamespace(
'a',
[]
[],
),
'a'
'a',
),
(
PythonPackageNamespace(
'1',
[]
[],
),
'1'
'1',
),
(
PythonPackageNamespace(
StrSubclass('a'),
[]
[],
),
StrSubclass('a')
StrSubclass('a'),
),
])
def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
@@ -52,7 +52,7 @@ def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
namespace_b = PythonModuleNamespace('b')
namespace_a = PythonPackageNamespace('a', [
namespace_b
namespace_b,
])
namespace_c = PythonModuleNamespace('c')
namespace_k = PythonModuleNamespace('k')
@@ -68,47 +68,47 @@ namespace_d = PythonPackageNamespace('d', [namespace_e])
(
PythonPackageNamespace(
'name',
[namespace_a, namespace_c]
[namespace_a, namespace_c],
),
['c'],
namespace_c
namespace_c,
),
(
PythonPackageNamespace(
'name',
[namespace_a, namespace_c]
[namespace_a, namespace_c],
),
['a'],
namespace_a
namespace_a,
),
(
PythonPackageNamespace(
'name',
[namespace_a, namespace_c]
[namespace_a, namespace_c],
),
['a', 'b'],
namespace_b
namespace_b,
),
(
namespace_d,
['e', 'f', 'g', 'h', 'i'],
namespace_i
namespace_i,
),
(
namespace_d,
['e', 'f', 'g', 'h', 'i', 'j'],
namespace_j
namespace_j,
),
(
namespace_d,
['e', 'f', 'g', 'h', 'i', 'j', 'k'],
namespace_k
namespace_k,
),
])
def test_PythonPackageNamespace_namespace(
namespace: PythonPackageNamespace,
sub_namespaces,
expected
expected,
):
assert namespace.namespace(sub_namespaces) == expected
@@ -119,39 +119,39 @@ def test_PythonPackageNamespace_namespace(
namespace_a,
['c'],
NamespaceNotFoundError,
'no such namespace: c'
'no such namespace: c',
),
(
namespace_h,
['i', 'k'],
NamespaceNotFoundError,
'no such namespace: k'
'no such namespace: k',
),
(
namespace_a,
['b', ''],
InvalidNamespaceError,
'invalid namespace'
'invalid namespace',
),
(
namespace_a,
['', 'b'],
InvalidNamespaceError,
'invalid namespace'
'invalid namespace',
),
(
namespace_a,
['b', '', 'b'],
InvalidNamespaceError,
'invalid namespace'
'invalid namespace',
),
]
],
)
def test_PythonPackageNamespace_namespace_exceptions(
namespace,
sub_namespaces,
expected_exception,
expected_exception_msg
expected_exception_msg,
):
with pytest.raises(expected_exception) as exc_info:
namespace.namespace(sub_namespaces)
@@ -161,9 +161,9 @@ def test_PythonPackageNamespace_namespace_exceptions(
(
PythonPackageNamespace(
'a',
[PythonModuleNamespace('b')]
[PythonModuleNamespace('b')],
),
{'b': 'b'}
{'b': 'b'},
),
(
PythonPackageNamespace(
@@ -172,19 +172,19 @@ def test_PythonPackageNamespace_namespace_exceptions(
PythonModuleNamespace('b'),
PythonPackageNamespace(
'c',
[PythonModuleNamespace('d')]
)
]
[PythonModuleNamespace('d')],
),
],
),
{
'b': 'b',
'c': {'d': 'd'}
}
'c': {'d': 'd'},
},
),
(
PythonPackageNamespace('a', []),
{}
)
{},
),
])
def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
assert namespace.sub_namespace_names() == expected
@@ -193,13 +193,13 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
(
PythonPackageNamespace(
'a',
[PythonModuleNamespace('b')]
[PythonModuleNamespace('b')],
),
PythonPackageNamespace(
'a',
[PythonModuleNamespace('b')]
[PythonModuleNamespace('b')],
),
True
True,
),
(
PythonPackageNamespace(
@@ -208,9 +208,9 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
PythonModuleNamespace('b'),
PythonPackageNamespace(
'c',
[PythonModuleNamespace('d')]
)
]
[PythonModuleNamespace('d')],
),
],
),
PythonPackageNamespace(
'a',
@@ -218,21 +218,21 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
PythonModuleNamespace('b'),
PythonPackageNamespace(
'c',
[PythonModuleNamespace('d')]
)
]
[PythonModuleNamespace('d')],
),
],
),
True
True,
),
(
PythonPackageNamespace('a', []),
PythonPackageNamespace('a', []),
True
True,
),
(
PythonPackageNamespace('a', []),
PythonPackageNamespace('b', []),
False
False,
),
])
def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
@@ -242,19 +242,19 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
@pytest.mark.parametrize('namespace,expected', [
(
PythonPackageNamespace('a', []),
'PythonPackageNamespace(\'a\', [])'
'PythonPackageNamespace(\'a\', [])',
),
(
PythonPackageNamespace('1', []),
'PythonPackageNamespace(\'1\', [])'
'PythonPackageNamespace(\'1\', [])',
),
(
PythonPackageNamespace(StrSubclass('a'), []),
'PythonPackageNamespace(\'a\', [])'
'PythonPackageNamespace(\'a\', [])',
),
(
namespace_a,
'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])'
'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])',
),
(
namespace_d,
@@ -264,8 +264,8 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
'geNamespace(\'g\', [PythonPackageNamespace(\'h\', [P'
'ythonPackageNamespace(\'i\', [PythonPackageNamespace'
'(\'j\', [PythonModuleNamespace(\'k\')])])])])])])])'
)
)
),
),
])
def test_PythonPackageNamespace_string_representation(namespace, expected):
assert repr(namespace) == expected
@@ -276,14 +276,14 @@ def test_PythonPackageNamespace_string_representation(namespace, expected):
PythonModuleNamespace('b'),
PythonPackageNamespace(
'a',
[PythonModuleNamespace('b')]
)
)
[PythonModuleNamespace('b')],
),
),
])
def test_PythonPackageNamespace___getitem__(
namespace,
new_namespace,
expected
expected,
):
namespace.add(new_namespace)
assert namespace == expected
@@ -34,33 +34,33 @@ def test_assert_that_is_instance(obj, class_or_tuple):
(
1,
str,
'expected \'str\', got \'int\''
'expected \'str\', got \'int\'',
),
(
1,
(str,),
'expected \'str\', got \'int\''
'expected \'str\', got \'int\'',
),
(
1,
str | float,
'expected either \'str\' or \'float\', got \'int\''
'expected either \'str\' or \'float\', got \'int\'',
),
(
1,
str | float | list,
'expected either \'str\', \'float\' or \'list\', got \'int\''
'expected either \'str\', \'float\' or \'list\', got \'int\'',
),
(
1,
TestType,
'expected \'NOT TestType\', got \'int\''
'expected \'NOT TestType\', got \'int\'',
),
])
def test_assert_that_is_instance_exceptions(
obj,
class_or_tuple,
expected_exception_msg
expected_exception_msg,
):
with pytest.raises(TypeError) as exc_info:
assert_that_is_instance(obj, class_or_tuple)
+1 -1
View File
@@ -52,7 +52,7 @@ import pytest
[1, 2, 3, 42, 'a', 23],
'and',
'\'',
'\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\''
'\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\'',
),
])
def test_human_readable_list(ls, final_separator, quotation_mark, expected):