File: test_warnings.py

package info (click to toggle)
python-griffe 1.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,292 kB
  • sloc: python: 17,202; makefile: 47; sh: 24; javascript: 13
file content (25 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Tests for the docstrings utility functions."""

from __future__ import annotations

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


def test_can_warn_without_parent_module() -> None:
    """Assert we can parse a docstring even if it does not have a parent module."""
    function = Function(
        "func",
        parameters=Parameters(
            Parameter("param1", annotation=None, kind=ParameterKind.positional_or_keyword),
            Parameter("param2", annotation="int", kind=ParameterKind.keyword_only),
        ),
    )
    text = """
    Hello I'm a docstring!

    Parameters:
        param1: Description.
        param2: Description.
    """
    docstring = Docstring(text, lineno=1, parent=function)
    assert parse(docstring, Parser.google)