File: test_docs.py

package info (click to toggle)
freeorion 0.5.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 194,920 kB
  • sloc: cpp: 186,821; python: 40,979; ansic: 1,164; xml: 721; makefile: 32; sh: 7
file content (36 lines) | stat: -rw-r--r-- 1,011 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
26
27
28
29
30
31
32
33
34
35
36
from stub_generator.parse_docs import Docs


def test_multiple_declaration_with_docstrings():
    text = """
getEmpire() -> empire :
    Returns B

getEmpire( (int)arg1) -> empire :
    Returns A
""".strip(
        "\n"
    )

    docs = Docs(text, indent=0, is_class=False)
    assert list(docs.get_argument_strings()) == ["", "number: int"]
    assert docs.get_doc_string() == ('"""\nReturns B\nReturns A\n"""')


def test_single_declaration_with_docstrings():
    text = """
empirePlayerID( (int)arg1) -> int :
    Returns ...
    """.strip(
        "\n"
    )
    docs = Docs(text, indent=0, is_class=False)
    assert list(docs.get_argument_strings()) == ["number: int"]
    assert docs.get_doc_string() == '"""\nReturns ...\n"""'


def test_docs_single_line():
    text = "inQueue( (researchQueue)arg1, (str)arg2) -> bool"
    docs = Docs(text, indent=0, is_class=False)
    assert list(docs.get_argument_strings()) == ["research_queue: researchQueue, string: str"]
    assert docs.get_doc_string() == ""