Skip to content

Commit

Permalink
add test for docdict order
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Scheltienne committed Jan 2, 2024
1 parent 4c3a625 commit 002ea42
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion template/utils/tests/test_docs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Test _docs.py"""

import re
from pathlib import Path

import pytest

from .._docs import copy_doc, fill_doc
from .._docs import copy_doc, docdict, fill_doc
from ..logs import verbose


Expand Down Expand Up @@ -207,3 +210,16 @@ def method4(verbose=None):
assert foo.method1.__doc__ == foo2.method2.__doc__
assert foo.method1.__doc__ == foo2.method3.__doc__
assert foo.method1.__doc__ == foo2.method4.__doc__


def test_docdict_order():
"""Test that docdict is alphabetical."""
# read the file as text, and get entries via regex
docs_path = Path(__file__).parents[1] / "_docs.py"
assert docs_path.is_file()
with open(docs_path, "r", encoding="UTF-8") as fid:
docs = fid.read()
entries = re.findall(r'docdict\[(?:\n )?["\'](.+)["\']\n?\] = ', docs)
# test length, uniqueness and order
assert len(docdict) == len(entries)
assert sorted(entries) == entries

0 comments on commit 002ea42

Please sign in to comment.