Skip to content

Commit

Permalink
Catch property errors using jaraco.test.property_error. Fixes #24.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 8, 2022
1 parent ffaa263 commit 972080c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
10 changes: 3 additions & 7 deletions cssutils/tests/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import xml.dom

import pytest
from jaraco.test import property_error

from . import basetest
import cssutils
Expand Down Expand Up @@ -158,17 +159,12 @@ def test_name(self):
self.assertEqual(r'c\olor', p.literalname)
self.assertEqual('color', p.name)

@pytest.mark.xfail(
"sys.version_info > (3, 11)",
reason="jaraco/cssutils#24",
)
def test_literalname(self):
"Property.literalname"
p = cssutils.css.property.Property(r'c\olor', 'red')
self.assertEqual(r'c\olor', p.literalname)
self.assertRaisesMsg(
AttributeError, "can't set attribute", p.__setattr__, 'literalname', 'color'
)
with pytest.raises(AttributeError, match=property_error("Property.literalname")):
p.literalname = 'color'

def test_validate(self):
"Property.valid"
Expand Down
11 changes: 3 additions & 8 deletions cssutils/tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import xml.dom

import pytest
from jaraco.test import property_error

from . import basetest
import cssutils
Expand Down Expand Up @@ -380,20 +381,14 @@ def test_selectorText(self):
# only set as not complete
self.do_raise_r(tests, att='_setSelectorText')

@pytest.mark.xfail(
"sys.version_info > (3, 11)",
reason="jaraco/cssutils#24",
)
def test_specificity(self):
"Selector.specificity"
selector = cssutils.css.Selector()

# readonly
def _set():
# property is read-only
with pytest.raises(AttributeError, match=property_error('Selector.specificity')):
selector.specificity = 1

self.assertRaisesMsg(AttributeError, "can't set attribute", _set)

tests = {
'*': (0, 0, 0, 0),
'li': (0, 0, 0, 1),
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ testing =
python_version < "3.11"
cssselect
importlib_resources; python_version < "3.9"
jaraco.test >= 5.1

docs =
# upstream
Expand Down

0 comments on commit 972080c

Please sign in to comment.