Skip to content

Commit 79db8ca

Browse files
committed
Replace xunit-style setup with pytest fixtures. Closes jaraco#45.
1 parent be47e45 commit 79db8ca

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

cssutils/tests/test_domimplementation.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@
44
import xml.dom.minidom
55
import warnings
66

7+
import pytest
8+
79
import cssutils
810

911

10-
class TestDOMImplementation:
11-
def setup_method(self):
12-
self.domimpl = cssutils.DOMImplementationCSS()
12+
@pytest.fixture
13+
def domimpl():
14+
return cssutils.DOMImplementationCSS()
1315

14-
def test_createCSSStyleSheet(self):
16+
17+
class TestDOMImplementation:
18+
def test_createCSSStyleSheet(self, domimpl):
1519
"DOMImplementationCSS.createCSSStyleSheet()"
1620
title, media = 'Test Title', cssutils.stylesheets.MediaList('all')
1721
with warnings.catch_warnings():
1822
warnings.simplefilter('ignore')
19-
sheet = self.domimpl.createCSSStyleSheet(title, media)
23+
sheet = domimpl.createCSSStyleSheet(title, media)
2024
assert isinstance(sheet, cssutils.css.CSSStyleSheet)
2125
assert title == sheet.title
2226
assert media == sheet.media
2327

24-
def test_createDocument(self):
28+
def test_createDocument(self, domimpl):
2529
"DOMImplementationCSS.createDocument()"
26-
doc = self.domimpl.createDocument(None, None, None)
30+
doc = domimpl.createDocument(None, None, None)
2731
assert isinstance(doc, xml.dom.minidom.Document)
2832

29-
def test_createDocumentType(self):
33+
def test_createDocumentType(self, domimpl):
3034
"DOMImplementationCSS.createDocumentType()"
31-
doctype = self.domimpl.createDocumentType('foo', 'bar', 'raboof')
35+
doctype = domimpl.createDocumentType('foo', 'bar', 'raboof')
3236
assert isinstance(doctype, xml.dom.minidom.DocumentType)
3337

34-
def test_hasFeature(self):
38+
def test_hasFeature(self, domimpl):
3539
"DOMImplementationCSS.hasFeature()"
3640
tests = [
3741
('css', '1.0'),
@@ -40,4 +44,4 @@ def test_hasFeature(self):
4044
('stylesheets', '2.0'),
4145
]
4246
for name, version in tests:
43-
assert self.domimpl.hasFeature(name, version)
47+
assert domimpl.hasFeature(name, version)

cssutils/tests/test_value.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
from . import basetest
99

1010

11-
class TestPropertyValue(basetest.BaseTestCase):
12-
def setup_method(self):
13-
self.r = cssutils.css.PropertyValue()
11+
@pytest.fixture
12+
def set_r_property_value(request):
13+
request.instance.r = cssutils.css.PropertyValue()
14+
1415

16+
@pytest.mark.usefixtures('set_r_property_value')
17+
class TestPropertyValue(basetest.BaseTestCase):
1518
def test_init(self):
1619
"PropertyValue.__init__() .item() .length"
1720
pv = cssutils.css.PropertyValue()

newsfragments/45.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace xunit-style setup with pytest fixtures.

0 commit comments

Comments
 (0)