Coverage for tests/test_properties.py: 100.00%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

26 statements  

1"""Tests for [the `properties` module][pytkdocs.properties].""" 

2 

3from pytkdocs.objects import Attribute, Class, Function, Method, Module 

4 

5 

6def test_name_properties_on_module(): 

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 

12 

13 

14def test_name_properties_on_class(): 

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 

20 

21 

22def test_name_properties_on_method(): 

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 

28 

29 

30def test_name_properties_on_function(): 

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 

36 

37 

38def test_name_properties_on_attribute(): 

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