Skip to content

Commit

Permalink
unittest2pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 9, 2022
1 parent ab10e94 commit 591039d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions cssutils/tests/test_encutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import http.client
from io import StringIO
import unittest

try:
import cssutils.encutils as encutils
Expand All @@ -14,7 +13,7 @@
log = encutils.buildlog(stream=StringIO())


class AutoEncodingTestCase(unittest.TestCase):
class AutoEncodingTestCase:
def _fakeRes(self, content):
"build a fake HTTP response"

Expand Down Expand Up @@ -54,7 +53,7 @@ def test_getTextTypeByMediaType(self):
'ANYTHING': encutils._OTHER_TYPE,
}
for test, exp in list(tests.items()):
self.assertEqual(exp, encutils._getTextTypeByMediaType(test, log=log))
assert exp == encutils._getTextTypeByMediaType(test, log=log)

def test_getTextType(self):
"encutils._getTextType"
Expand All @@ -74,7 +73,7 @@ def test_getTextType(self):
'ANYTHING': encutils._OTHER_TYPE,
}
for test, exp in list(tests.items()):
self.assertEqual(exp, encutils._getTextType(test, log=log))
assert exp == encutils._getTextType(test, log=log)

def test_encodingByMediaType(self):
"encutils.encodingByMediaType"
Expand All @@ -93,7 +92,7 @@ def test_encodingByMediaType(self):
'ANYTHING': None,
}
for test, exp in list(tests.items()):
self.assertEqual(exp, encutils.encodingByMediaType(test, log=log))
assert exp == encutils.encodingByMediaType(test, log=log)

def test_getMetaInfo(self):
"encutils.getMetaInfo"
Expand Down Expand Up @@ -186,7 +185,7 @@ def test_getMetaInfo(self):
),
}
for test, exp in list(tests.items()):
self.assertEqual(exp, encutils.getMetaInfo(test, log=log))
assert exp == encutils.getMetaInfo(test, log=log)

def test_detectXMLEncoding(self):
"encutils.detectXMLEncoding"
Expand All @@ -206,7 +205,7 @@ def test_detectXMLEncoding(self):
(('utf-8'), '<?xml version="1.0"?><x encoding="ascii"/>'),
)
for exp, test in tests:
self.assertEqual(exp, encutils.detectXMLEncoding(test, log=log))
assert exp == encutils.detectXMLEncoding(test, log=log)

def test_tryEncodings(self):
"encutils.tryEncodings"
Expand All @@ -225,7 +224,7 @@ def test_tryEncodings(self):
# ('utf-8', u'\u1111'.encode('utf-8'))
]
for exp, test in tests:
self.assertEqual(exp, encutils.tryEncodings(test))
assert exp == encutils.tryEncodings(test)

def test_getEncodingInfo(self):
"encutils.getEncodingInfo"
Expand Down Expand Up @@ -464,8 +463,4 @@ def test_getEncodingInfo(self):
res = encutils.getEncodingInfo(text=text)

res = (res.encoding, res.mismatch)
self.assertEqual(exp, res)


if __name__ == '__main__':
unittest.main()
assert exp == res

0 comments on commit 591039d

Please sign in to comment.