Skip to content

Commit

Permalink
Patch file_regression fixture for sphinx backwards compatibility (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
je-cook authored Sep 18, 2023
1 parent 5fe1ce2 commit 540b756
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,26 @@ def _func(doctree):
return doctree

return _func


# TODO Remove when support for Sphinx<=6 is dropped,
# 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 = (" translation_progress=\"{'total': 0, 'translated': 0}\"",)

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 = data.replace(ig, "")
return data

0 comments on commit 540b756

Please sign in to comment.