Skip to content

Commit c4ebbbc

Browse files
committed
clean up tests
1 parent 2f0c279 commit c4ebbbc

File tree

1 file changed

+10
-33
lines changed

1 file changed

+10
-33
lines changed

quartodoc/tests/test_validation.py

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,41 @@
1919
'contents': [{'kind': 'auto', 'name': 'Builder', 'members': []},
2020
'Builder.from_quarto_config', 'Builder.build', 'Builder.write_index', 'Builder.write_doc_pages', 'Builder.write_sidebar', 'Builder.create_inventory']
2121
},
22-
{'title': 'Inventory links', 'desc': 'Inventory files map a functions name to its corresponding url in your docs.\nThese functions allow you to create and transform inventory files.\n',
23-
'contents': ['create_inventory', 'convert_inventory']
24-
},
25-
{'title': 'Data models: structural',
26-
'desc': 'Classes for specifying the broad structure your docs.\n',
27-
'contents': [{'kind': 'page',
28-
'path': 'layouts-structure',
29-
'flatten': True,
30-
'contents': ['layout.Layout', 'layout.Section', 'layout.Page', 'layout.ContentElement']}]
31-
},
32-
{'title': 'Data models: docable', 'desc': 'Classes representing python objects to be rendered.\n',
33-
'contents': [{'kind': 'page',
34-
'path': 'layouts-docable',
35-
'flatten': True,
36-
'contents': [{'name': 'layout.Doc', 'members': []}, 'layout.DocFunction', 'layout.DocAttribute', 'layout.DocModule', 'layout.DocClass', 'layout.Link', 'layout.Item', 'layout.ChoicesChildren']}]
37-
},
38-
{'title': 'Data models: docstring patches',
39-
'desc': 'Most of the classes for representing python objects live\nin [](`griffe.dataclasses`) or [](`griffe.docstrings.dataclasses`).\nHowever, the `quartodoc.ast` module has a number of custom classes to fill\nin support for some important docstring sections.\n',
40-
'contents': ['ast.DocstringSectionSeeAlso', 'ast.DocstringSectionNotes', 'ast.DocstringSectionWarnings', 'ast.ExampleCode', 'ast.ExampleText']
41-
}
4222
]
4323

24+
@pytest.fixture
25+
def sections():
26+
return copy.deepcopy(EXAMPLE_SECTIONS)
4427

28+
def test_valid_yaml(sections):
29+
Builder(sections=sections, package='quartodoc')
4530

46-
def test_valid_yaml():
47-
Builder(sections=EXAMPLE_SECTIONS, package='quartodoc')
48-
49-
def test_missing_title():
50-
sections = copy.deepcopy(EXAMPLE_SECTIONS)
31+
def test_missing_title(sections):
5132
del sections[0]['title']
5233
with pytest.raises(ValueError) as e:
5334
Builder(sections=sections, package='quartodoc')
5435
assert '- Missing field `title` for element 0 in the list for `sections`' in str(e.value)
5536

56-
57-
def test_missing_desc():
37+
def test_missing_desc(sections):
5838
sections = copy.deepcopy(EXAMPLE_SECTIONS)
5939
del sections[2]['desc']
6040
with pytest.raises(ValueError) as e:
6141
Builder(sections=sections, package='quartodoc')
6242
assert '- Missing field `desc` for element 2 in the list for `sections`' in str(e.value)
6343

64-
def test_missing_name_contents_1():
65-
sections = copy.deepcopy(EXAMPLE_SECTIONS)
44+
def test_missing_name_contents_1(sections):
6645
del sections[2]['contents'][0]['name']
6746
with pytest.raises(ValueError) as e:
6847
Builder(sections=sections, package='quartodoc')
6948
assert '- Missing field `name` for element 0 in the list for `contents` located in element 2 in the list for `sections`' in str(e.value)
7049

71-
def test_missing_name_contents_2():
72-
sections = copy.deepcopy(EXAMPLE_SECTIONS)
50+
def test_missing_name_contents_2(sections):
7351
del sections[1]['contents'][0]['name']
7452
with pytest.raises(ValueError) as e:
7553
Builder(sections=sections, package='quartodoc')
7654
assert '- Missing field `name` for element 0 in the list for `contents` located in element 1 in the list for `sections`' in str(e.value)
7755

78-
def test_misplaced_kindpage():
79-
sections = copy.deepcopy(EXAMPLE_SECTIONS)
56+
def test_misplaced_kindpage(sections):
8057
sections[0]['kind'] = 'page'
8158
with pytest.raises(ValueError) as e:
8259
Builder(sections=sections, package='quartodoc')

0 commit comments

Comments
 (0)