Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/jaraco/cssutils
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 24, 2021
2 parents 0fc6515 + cdffe59 commit 39a349a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
import pytest

import cssutils


collect_ignore = [
'cssutils/_fetchgae.py',
'tools',
]


@pytest.fixture(autouse=True)
def hermetic_profiles():
"""
Ensure that tests are hermetic w.r.t. profiles.
"""
before = list(cssutils.profile.profiles)
yield
assert before == cssutils.profile.profiles


@pytest.fixture
def saved_profiles(monkeypatch):
profiles = cssutils.profiles.Profiles(log=cssutils.log)
monkeypatch.setattr(cssutils, 'profile', profiles)
1 change: 1 addition & 0 deletions cssutils/tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def check(*results):
# restore
cssutils.profile = saved

@pytest.mark.usefixtures('saved_profiles')
def test_addProfile(self):
"Profiles.addProfile with custom validation function"
# unknown profile
Expand Down
4 changes: 2 additions & 2 deletions examples/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def profile():
"""
>>> sheet = cssutils.parseString('x { -test-custommacro: x }')
The following fails in a full suite test run due to non-hermetic tests.
>>> print(sheet.cssRules[0].style.getProperties()[0].valid) # doctest: +SKIP
>>> print(sheet.cssRules[0].style.getProperties()[0].valid)
False
>>> M1 = {
... 'testvalue': 'x'
Expand All @@ -24,6 +23,7 @@ def profile():
... # custom validation function
... '-test-funcval': lambda v: int(v) > 0
... }
>>> profiles = getfixture('saved_profiles') # keep test hermetic
>>> cssutils.profile.addProfile('test', P1, M1)
>>> sheet = cssutils.parseString('x { -test-custommacro: x }')
>>> print(sheet.cssRules[0].style.getProperties()[0].valid)
Expand Down

0 comments on commit 39a349a

Please sign in to comment.