Coverage for tests/test_properties.py: 100.00%
26 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-09 17:28 +0100
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-09 17:28 +0100
1"""Tests for [the `properties` module][pytkdocs.properties]."""
3from pytkdocs.objects import Attribute, Class, Function, Method, Module
6def test_name_properties_on_module() -> None:
7 """Check module name properties."""
8 assert not Module(name="a", path="a", file_path="a.py").name_properties
9 assert "private" in Module(name="_a", path="a", file_path="_a.py").name_properties
10 assert not Module(name="__a", path="__a", file_path="__a.py").name_properties
11 assert "special" in Module(name="__a__", path="a", file_path="__a__.py").name_properties
14def test_name_properties_on_class() -> None:
15 """Check class name properties."""
16 assert not Class(name="b", path="a.b", file_path="a.py").name_properties
17 assert "private" in Class(name="_b", path="a._b", file_path="a.py").name_properties
18 assert not Class(name="__b", path="a.__b", file_path="a.py").name_properties
19 assert not Class(name="__b__", path="a.__b__", file_path="a.py").name_properties
22def test_name_properties_on_method() -> None:
23 """Check method name properties."""
24 assert not Method(name="c", path="a.b.c", file_path="a.py").name_properties
25 assert "private" in Method(name="_c", path="a.b._c", file_path="a.py").name_properties
26 assert not Method(name="__c", path="a.b.__c", file_path="a.py").name_properties
27 assert "special" in Method(name="__c__", path="a.b.__c__", file_path="a.py").name_properties
30def test_name_properties_on_function() -> None:
31 """Check function name properties."""
32 assert not Function(name="b", path="a.b", file_path="a.py").name_properties
33 assert "private" in Function(name="_b", path="a._b", file_path="a.py").name_properties
34 assert not Function(name="__b", path="a.__b", file_path="a.py").name_properties
35 assert not Function(name="__b__", path="a.__b__", file_path="a.py").name_properties
38def test_name_properties_on_attribute() -> None:
39 """Check attribute name properties."""
40 assert not Attribute(name="b", path="a.b", file_path="a.py").name_properties
41 assert "private" in Attribute(name="_b", path="a._b", file_path="a.py").name_properties
42 assert "class-private" in Attribute(name="__b", path="a.__b", file_path="a.py").name_properties
43 assert "special" in Attribute(name="__b__", path="a.__b__", file_path="a.py").name_properties