File: test_selector.py

package info (click to toggle)
python-setuptools-rust 1.9.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 648 kB
  • sloc: python: 1,703; javascript: 95; sh: 14; makefile: 13
file content (23 lines) | stat: -rwxr-xr-x 621 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
from glob import glob
import os

import html_py_ever
import pytest
from bs4 import BeautifulSoup


HTML_FILES = glob(os.path.join(os.path.dirname(__file__), "*.html"))


@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_selector_rust(benchmark, filename):
    document = html_py_ever.parse_file(filename)
    benchmark(document.select, "a[href]")


@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_selector_python(benchmark, filename):
    with open(filename, encoding="utf8") as fp:
        soup = BeautifulSoup(fp, "html.parser")
    benchmark(soup.select, "a[href]")