Coverage for tests/test_docstrings/test_warnings.py: 100.00%

7 statements  

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

1"""Tests for the docstrings utility functions.""" 

2 

3from __future__ import annotations 

4 

5from griffe import Docstring, Function, Parameter, ParameterKind, Parameters, Parser, parse 

6 

7 

8def test_can_warn_without_parent_module() -> None: 

9 """Assert we can parse a docstring even if it does not have a parent module.""" 

10 function = Function( 

11 "func", 

12 parameters=Parameters( 

13 Parameter("param1", annotation=None, kind=ParameterKind.positional_or_keyword), # I only changed this line 

14 Parameter("param2", annotation="int", kind=ParameterKind.keyword_only), 

15 ), 

16 ) 

17 text = """ 

18 Hello I'm a docstring! 

19 

20 Parameters: 

21 param1: Description. 

22 param2: Description. 

23 """ 

24 docstring = Docstring(text, lineno=1, parent=function) 

25 assert parse(docstring, Parser.google)