Coverage for tests/test_public_api.py: 100.00%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.2, created at 2024-10-12 01:34 +0200

1"""Tests for public API handling.""" 

2 

3from griffe import temporary_visited_module 

4 

5 

6def test_not_detecting_imported_objects_as_public() -> None: 

7 """Imported objects not listed in `__all__` must not be considered public.""" 

8 with temporary_visited_module("from abc import ABC\ndef func(): ...") as module: 

9 assert not module["ABC"].is_public 

10 assert module["func"].is_public # control case 

11 

12 

13def test_detecting_dunder_attributes_as_public() -> None: 

14 """Dunder attributes (methods, etc.) must be considered public.""" 

15 with temporary_visited_module( 

16 """ 

17 def __getattr__(name): ... 

18 class A: 

19 def __init__(self): ... 

20 """, 

21 ) as module: 

22 assert module["__getattr__"].is_public 

23 assert module["A.__init__"].is_public