-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathconftest.py
58 lines (39 loc) · 1.18 KB
/
conftest.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
from bs4 import BeautifulSoup
from pathlib import Path
from sphinx.application import Sphinx
pytest_plugins = "sphinx.testing.fixtures"
@pytest.fixture(scope="session")
def rootdir():
return Path(__file__).parent.absolute() / "roots"
@pytest.fixture()
def content(app):
app.build()
yield app
def _meta_tags(content, subdir=None):
if subdir is None:
c = (content.outdir / "index.html").read_text()
else:
c = (content.outdir / subdir / "index.html").read_text()
return BeautifulSoup(c, "html.parser").find_all("meta")
def _og_meta_tags(content):
return [
tag for tag in _meta_tags(content) if tag.get("property", "").startswith("og:")
]
@pytest.fixture()
def meta_tags(content):
return _meta_tags(content)
@pytest.fixture()
def og_meta_tags(content):
return [
tag for tag in _meta_tags(content) if tag.get("property", "").startswith("og:")
]
@pytest.fixture()
def og_meta_tags_sub(content):
return [
tag
for tag in _meta_tags(content, "sub")
if tag.get("property", "").startswith("og:")
]
def pytest_configure(config):
config.addinivalue_line("markers", "sphinx")