File: test_docs.py

package info (click to toggle)
sqlglot 30.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,644 kB
  • sloc: python: 96,110; sql: 23,456; makefile: 75
file content (32 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import doctest
import importlib
import pkgutil
import unittest

import sqlglot


def load_tests(loader, tests, ignore):
    """
    This finds and runs all the doctests
    """

    modules = set()
    for info in pkgutil.walk_packages(sqlglot.__path__, prefix="sqlglot."):
        if info.name == "sqlglot.__main__":
            continue
        try:
            modules.add(importlib.import_module(info.name))
        except Exception:
            continue

    assert len(modules) >= 20

    for module in sorted(modules, key=lambda m: m.__name__):
        tests.addTests(doctest.DocTestSuite(module))

    return tests


if __name__ == "__main__":
    unittest.main()