From b69a3381381aabd97873903eea863a85fc4c932d Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sun, 10 Jun 2012 15:20:10 -0700 Subject: [PATCH] Add a test for main-tables.rst --- pokedex/tests/test_docs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pokedex/tests/test_docs.py diff --git a/pokedex/tests/test_docs.py b/pokedex/tests/test_docs.py new file mode 100644 index 0000000..3cd5f68 --- /dev/null +++ b/pokedex/tests/test_docs.py @@ -0,0 +1,22 @@ +import os +import re + +from pokedex.db.tables import mapped_classes + +def test_main_tables(): + """Check that tables.py and main-tables.rst are in sync: every table should + be documented, and every documented table should exist.""" + + main_tables_path = os.path.join(os.path.dirname(__file__), '../../doc/main-tables.rst') + + with open(main_tables_path) as f: + doc_class_names = set( + re.findall(r'^\.\. dex-table:: (\w+)$', f.read(), re.MULTILINE) + ) + + mapped_class_names = set(cls.__name__ for cls in mapped_classes) + + # EXTRA ITEMS IN THE LEFT SET: tables defined but not documented + # EXTRA ITEMS IN THE RIGHT SET: tables documented but not defined + assert mapped_class_names == doc_class_names +