File: test_linkify.py

package info (click to toggle)
linkify-it-py 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 204 kB
  • sloc: python: 2,268; makefile: 8
file content (40 lines) | stat: -rw-r--r-- 890 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
from pathlib import Path

import pytest

from linkify_it import LinkifyIt

from .utils import read_fixture_file

FIXTURE_PATH = Path(__file__).parent / "fixtures"


def dummy(_):
    pass


@pytest.mark.parametrize(
    "number,line,expected",
    read_fixture_file(FIXTURE_PATH.joinpath("links.txt")),
)
def test_links(number, line, expected):
    linkifyit = LinkifyIt(options={"fuzzy_ip": True})

    linkifyit.normalize = dummy

    assert linkifyit.pretest(line) is True
    assert linkifyit.test("\n" + line + "\n") is True
    assert linkifyit.test(line) is True
    assert linkifyit.match(line)[0].url == expected


@pytest.mark.parametrize(
    "number,line,expected",
    read_fixture_file(FIXTURE_PATH.joinpath("not_links.txt")),
)
def test_not_links(number, line, expected):
    linkifyit = LinkifyIt()

    linkifyit.normalize = dummy

    assert linkifyit.test(line) is False