Skip to content

Commit

Permalink
unittests: make datatests capable of parsing module subsections properly
Browse files Browse the repository at this point in the history
We will need to update the tests for each module that gets newly added,
apparently, but the basic structure for doing so is hopefully there.
  • Loading branch information
eli-schwartz committed Apr 14, 2022
1 parent 6a287fa commit 5df0fb4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions unittests/datatests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ def test_builtin_options_documented(self):
found_entries = set()
sections = re.finditer(r"^## (.+)$", md, re.MULTILINE)
# Extract the content for this section
u_subcontents = []
content = self._get_section_content("Universal options", sections, md)
subsections = tee(re.finditer(r"^### (.+)$", content, re.MULTILINE))
subcontent1 = self._get_section_content("Directories", subsections[0], content)
subcontent2 = self._get_section_content("Core options", subsections[1], content)
subcontent3 = self._get_section_content("Module options", sections, md)
for subcontent in (subcontent1, subcontent2, subcontent3):
u_subcontents.append(self._get_section_content("Directories", subsections[0], content))
u_subcontents.append(self._get_section_content("Core options", subsections[1], content))

mod_subcontents = []
content = self._get_section_content("Module options", sections, md)
subsections = tee(re.finditer(r"^### (.+)$", content, re.MULTILINE))
for idx, mod in enumerate(['Python']):
mod_subcontents.append(self._get_section_content(f'{mod} module', subsections[idx], content))
for subcontent in u_subcontents + mod_subcontents:
# Find the option names
options = set()
# Match either a table row or a table heading separator: | ------ |
Expand All @@ -151,9 +157,9 @@ def test_builtin_options_documented(self):
# setting of builtin options behaves
#
# Find all tables inside this subsection
tables = re.finditer(r"^\| (\w+) .* \|\n\| *[-|\s]+ *\|$", subcontent2, re.MULTILINE)
tables = re.finditer(r"^\| (\w+) .* \|\n\| *[-|\s]+ *\|$", u_subcontents[1], re.MULTILINE)
# Get the table we want using the header of the first column
table = self._get_section_content('buildtype', tables, subcontent2)
table = self._get_section_content('buildtype', tables, u_subcontents[1])
# Get table row data
rows = re.finditer(r"^\|(?: (\w+)\s+\| (\w+)\s+\| (\w+) .* | *-+ *)\|", table, re.MULTILINE)
env = get_fake_env()
Expand Down

0 comments on commit 5df0fb4

Please sign in to comment.