File: test_plain.py

package info (click to toggle)
python-docstring-to-markdown 0.15-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 228 kB
  • sloc: python: 1,761; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 999 bytes parent folder | download
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
37
38
39
40
41
42
import pytest
from docstring_to_markdown.plain import looks_like_plain_text, plain_text_to_markdown


@pytest.mark.parametrize("text", [
    "This is a sentence.",
    "Exclamation!",
    "Can I ask a question?",
    "Let's send an e-mail",
    "Parentheses (are) fine (really)",
    "Double \"quotes\" and single 'quotes'"
])
def test_accepts_english(text):
    assert looks_like_plain_text(text) is True


@pytest.mark.parametrize("text", [
    "[link label](https://link)",
    "![image label](https://source)",
    "Some **bold** text",
    "More __bold__ text",
    "Some *italic* text",
    "More _italic_ text"
])
def test_rejects_markdown(text):
    assert looks_like_plain_text(text) is False


@pytest.mark.parametrize("text", [
    "def test():",
    "print(123)",
    "func(arg)",
    "2 + 2",
    "var['test']",
    "x = 'test'"
])
def test_rejects_code(text):
    assert looks_like_plain_text(text) is False


def test_conversion():
    assert plain_text_to_markdown("test") == "test"