Skip to content

Commit

Permalink
Replace xunit-style setup with pytest fixtures. Closes #45.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 30, 2024
1 parent be47e45 commit 79db8ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
26 changes: 15 additions & 11 deletions cssutils/tests/test_domimplementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@
import xml.dom.minidom
import warnings

import pytest

import cssutils


class TestDOMImplementation:
def setup_method(self):
self.domimpl = cssutils.DOMImplementationCSS()
@pytest.fixture
def domimpl():
return cssutils.DOMImplementationCSS()

def test_createCSSStyleSheet(self):

class TestDOMImplementation:
def test_createCSSStyleSheet(self, domimpl):
"DOMImplementationCSS.createCSSStyleSheet()"
title, media = 'Test Title', cssutils.stylesheets.MediaList('all')
with warnings.catch_warnings():
warnings.simplefilter('ignore')
sheet = self.domimpl.createCSSStyleSheet(title, media)
sheet = domimpl.createCSSStyleSheet(title, media)
assert isinstance(sheet, cssutils.css.CSSStyleSheet)
assert title == sheet.title
assert media == sheet.media

def test_createDocument(self):
def test_createDocument(self, domimpl):
"DOMImplementationCSS.createDocument()"
doc = self.domimpl.createDocument(None, None, None)
doc = domimpl.createDocument(None, None, None)
assert isinstance(doc, xml.dom.minidom.Document)

def test_createDocumentType(self):
def test_createDocumentType(self, domimpl):
"DOMImplementationCSS.createDocumentType()"
doctype = self.domimpl.createDocumentType('foo', 'bar', 'raboof')
doctype = domimpl.createDocumentType('foo', 'bar', 'raboof')
assert isinstance(doctype, xml.dom.minidom.DocumentType)

def test_hasFeature(self):
def test_hasFeature(self, domimpl):
"DOMImplementationCSS.hasFeature()"
tests = [
('css', '1.0'),
Expand All @@ -40,4 +44,4 @@ def test_hasFeature(self):
('stylesheets', '2.0'),
]
for name, version in tests:
assert self.domimpl.hasFeature(name, version)
assert domimpl.hasFeature(name, version)
9 changes: 6 additions & 3 deletions cssutils/tests/test_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
from . import basetest


class TestPropertyValue(basetest.BaseTestCase):
def setup_method(self):
self.r = cssutils.css.PropertyValue()
@pytest.fixture
def set_r_property_value(request):
request.instance.r = cssutils.css.PropertyValue()


@pytest.mark.usefixtures('set_r_property_value')
class TestPropertyValue(basetest.BaseTestCase):
def test_init(self):
"PropertyValue.__init__() .item() .length"
pv = cssutils.css.PropertyValue()
Expand Down
1 change: 1 addition & 0 deletions newsfragments/45.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace xunit-style setup with pytest fixtures.

0 comments on commit 79db8ca

Please sign in to comment.