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
+140
-123
@@ -17,152 +17,169 @@ import pytest
|
||||
from jcloud_docsgen.cli.cli import create_argument_parser, main as cli_main
|
||||
from jcloud_docsgen.cli.languages.python import parse_sections_list
|
||||
from jcloud_docsgen.core.python import (
|
||||
PythonDefinitionDocumentationIncludeSections
|
||||
PythonDefinitionDocumentationIncludeSections,
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize('include,exclude,expected', [
|
||||
(
|
||||
[],
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = False,
|
||||
returns = False,
|
||||
params = False,
|
||||
exceptions = False,
|
||||
examples = False,
|
||||
docstring = False,
|
||||
bases = False,
|
||||
decorators = False,
|
||||
class_body = False,
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'include,exclude,expected',
|
||||
[
|
||||
(
|
||||
[],
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=False,
|
||||
returns=False,
|
||||
params=False,
|
||||
exceptions=False,
|
||||
examples=False,
|
||||
docstring=False,
|
||||
bases=False,
|
||||
decorators=False,
|
||||
class_body=False,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
[],
|
||||
['signature'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = False,
|
||||
returns = False,
|
||||
params = False,
|
||||
exceptions = False,
|
||||
examples = False,
|
||||
docstring = False,
|
||||
bases = False,
|
||||
decorators = False,
|
||||
class_body = False,
|
||||
(
|
||||
[],
|
||||
['signature'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=False,
|
||||
returns=False,
|
||||
params=False,
|
||||
exceptions=False,
|
||||
examples=False,
|
||||
docstring=False,
|
||||
bases=False,
|
||||
decorators=False,
|
||||
class_body=False,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
['signature'],
|
||||
['signature'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = False,
|
||||
returns = False,
|
||||
params = False,
|
||||
exceptions = False,
|
||||
examples = False,
|
||||
docstring = False,
|
||||
bases = False,
|
||||
decorators = False,
|
||||
class_body = False,
|
||||
(
|
||||
['signature'],
|
||||
['signature'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=False,
|
||||
returns=False,
|
||||
params=False,
|
||||
exceptions=False,
|
||||
examples=False,
|
||||
docstring=False,
|
||||
bases=False,
|
||||
decorators=False,
|
||||
class_body=False,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
['signature'],
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = True,
|
||||
returns = False,
|
||||
params = False,
|
||||
exceptions = False,
|
||||
examples = False,
|
||||
docstring = False,
|
||||
bases = False,
|
||||
decorators = False,
|
||||
class_body = False,
|
||||
(
|
||||
['signature'],
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=True,
|
||||
returns=False,
|
||||
params=False,
|
||||
exceptions=False,
|
||||
examples=False,
|
||||
docstring=False,
|
||||
bases=False,
|
||||
decorators=False,
|
||||
class_body=False,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
None,
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(),
|
||||
),
|
||||
(
|
||||
['signature', 'exceptions', 'bases', 'class_body'],
|
||||
['signature', 'bases'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = False,
|
||||
returns = False,
|
||||
params = False,
|
||||
exceptions = True,
|
||||
examples = False,
|
||||
docstring = False,
|
||||
bases = False,
|
||||
decorators = False,
|
||||
class_body = True,
|
||||
(
|
||||
None,
|
||||
[],
|
||||
PythonDefinitionDocumentationIncludeSections(),
|
||||
),
|
||||
),
|
||||
(
|
||||
None,
|
||||
['params', 'docstring'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature = True,
|
||||
returns = True,
|
||||
params = False,
|
||||
exceptions = True,
|
||||
examples = True,
|
||||
docstring = False,
|
||||
bases = True,
|
||||
decorators = True,
|
||||
class_body = True,
|
||||
(
|
||||
['signature', 'exceptions', 'bases', 'class_body'],
|
||||
['signature', 'bases'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=False,
|
||||
returns=False,
|
||||
params=False,
|
||||
exceptions=True,
|
||||
examples=False,
|
||||
docstring=False,
|
||||
bases=False,
|
||||
decorators=False,
|
||||
class_body=True,
|
||||
),
|
||||
),
|
||||
)
|
||||
])
|
||||
(
|
||||
None,
|
||||
['params', 'docstring'],
|
||||
PythonDefinitionDocumentationIncludeSections(
|
||||
signature=True,
|
||||
returns=True,
|
||||
params=False,
|
||||
exceptions=True,
|
||||
examples=True,
|
||||
docstring=False,
|
||||
bases=True,
|
||||
decorators=True,
|
||||
class_body=True,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_sections_list(include, exclude, expected):
|
||||
assert parse_sections_list(include, exclude) == expected
|
||||
|
||||
|
||||
def test_sections_error():
|
||||
parser = create_argument_parser()
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
parser.parse_args([
|
||||
'python',
|
||||
'-s',
|
||||
'param', # correct: `params`
|
||||
])
|
||||
parser.parse_args(
|
||||
[
|
||||
'python',
|
||||
'-s',
|
||||
'param', # correct: `params`
|
||||
]
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
parser.parse_args([
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstrng', # correct: `docstring`
|
||||
])
|
||||
parser.parse_args(
|
||||
[
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstrng', # correct: `docstring`
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_sections_success():
|
||||
parser = create_argument_parser()
|
||||
|
||||
parser.parse_args([
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
])
|
||||
parser.parse_args([
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstring',
|
||||
])
|
||||
parser.parse_args(
|
||||
[
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
]
|
||||
)
|
||||
parser.parse_args(
|
||||
[
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstring',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_docs_generation(expectdir):
|
||||
with expectdir('python_project') as output_dir:
|
||||
output_dir: pathlib.Path
|
||||
input_dir = pathlib.Path(__file__).parent / 'python_project/project'
|
||||
cli_main([
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstring',
|
||||
'-HTo',
|
||||
str(output_dir),
|
||||
str(input_dir),
|
||||
])
|
||||
cli_main(
|
||||
[
|
||||
'python',
|
||||
'-s',
|
||||
'params',
|
||||
'docstring',
|
||||
'-HTo',
|
||||
str(output_dir),
|
||||
str(input_dir),
|
||||
]
|
||||
)
|
||||
Reference in new issue
Block a user