| 1 |
# |
| 2 |
# Run tests after Twisted's the documentation is executed. |
| 3 |
# |
| 4 |
# These tests are designed to be executed inside tox, after bin/admin/build-apidocs. |
| 5 |
# Alternatively this can be excuted manually from the project root folder like: |
| 6 |
# pytest docs/tests/test_twisted_docs.py |
| 7 |
|
| 8 |
from . import get_toxworkdir_subdir |
| 9 |
|
| 10 |
BASE_DIR = get_toxworkdir_subdir('twisted-apidocs-build') |
| 11 |
|
| 12 |
# Test for https://github.com/twisted/pydoctor/issues/428 |
| 13 |
def test_IPAddress_implementations() -> None: |
| 14 |
""" |
| 15 |
This test ensures all important subclasses of IAddress show up in the IAddress class page documentation. |
| 16 |
""" |
| 17 |
|
| 18 |
show_up = ['twisted.internet.address.IPv4Address', |
| 19 |
'twisted.internet.address.IPv6Address', |
| 20 |
'twisted.internet.address.HostnameAddress', |
| 21 |
'twisted.internet.address.UNIXAddress'] |
| 22 |
|
| 23 |
with open(BASE_DIR / 'twisted.internet.interfaces.IAddress.html') as stream: |
| 24 |
page = stream.read() |
| 25 |
assert all(impl in page for impl in show_up), page |
| 26 |
|
| 27 |
# Test for https://github.com/twisted/pydoctor/issues/505 |
| 28 |
def test_web_template_api() -> None: |
| 29 |
""" |
| 30 |
This test ensures all important members of the twisted.web.template |
| 31 |
module are documented at the right place |
| 32 |
""" |
| 33 |
|
| 34 |
exists = ['twisted.web.template.Tag.html', |
| 35 |
'twisted.web.template.slot.html', |
| 36 |
'twisted.web.template.Comment.html', |
| 37 |
'twisted.web.template.CDATA.html', |
| 38 |
'twisted.web.template.CharRef.html', |
| 39 |
'twisted.web.template.TagLoader.html', |
| 40 |
'twisted.web.template.XMLString.html', |
| 41 |
'twisted.web.template.XMLFile.html', |
| 42 |
'twisted.web.template.Element.html',] |
| 43 |
for e in exists: |
| 44 |
assert (BASE_DIR / e).exists(), f"{e} not found" |
| 45 |
|
| 46 |
show_up = [ |
| 47 |
'twisted.web.template.renderer', |
| 48 |
'twisted.web.template.flatten', |
| 49 |
'twisted.web.template.flattenString', |
| 50 |
'twisted.web.template.renderElement'] |
| 51 |
|
| 52 |
with open(BASE_DIR / 'twisted.web.template.html') as stream: |
| 53 |
page = stream.read() |
| 54 |
assert all(impl in page for impl in show_up), page |