-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathconftest.py
32 lines (23 loc) · 917 Bytes
/
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
import re
import pytest
pytest_plugins = "sphinx.testing.fixtures"
# comparison files will need updating
# alternatively the resolution of https://github.com/ESSS/pytest-regressions/issues/32
@pytest.fixture()
def file_regression(file_regression):
return FileRegression(file_regression)
class FileRegression:
ignores = (
# TODO: Remove when support for Sphinx<=6 is dropped,
re.escape(" translation_progress=\"{'total': 0, 'translated': 0}\""),
# TODO: Remove when support for Sphinx<7.2 is dropped,
r"original_uri=\"[^\"]*\"\s",
)
def __init__(self, file_regression):
self.file_regression = file_regression
def check(self, data, **kwargs):
return self.file_regression.check(self._strip_ignores(data), **kwargs)
def _strip_ignores(self, data):
for ig in self.ignores:
data = re.sub(ig, "", data)
return data