Skip to content

Commit 31b8ecd

Browse files
committed
Test the TypeError of to_bytes() and to_unicode()
1 parent 3f50548 commit 31b8ecd

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/test_util.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from unittest import TestCase
22

3-
from pytest import deprecated_call
3+
from pytest import deprecated_call, raises
44

5-
from w3lib.util import str_to_unicode, to_native_str, unicode_to_str
5+
from w3lib.util import (
6+
str_to_unicode,
7+
to_bytes,
8+
to_native_str,
9+
to_unicode,
10+
unicode_to_str,
11+
)
612

713

814
class StrToUnicodeTestCase(TestCase):
@@ -12,13 +18,27 @@ def test_deprecation(self):
1218
str_to_unicode('')
1319

1420

21+
class ToBytesTestCase(TestCase):
22+
23+
def test_type_error(self):
24+
with raises(TypeError):
25+
to_bytes(True)
26+
27+
1528
class ToNativeStrTestCase(TestCase):
1629

1730
def test_deprecation(self):
1831
with deprecated_call():
1932
to_native_str('')
2033

2134

35+
class ToUnicodeTestCase(TestCase):
36+
37+
def test_type_error(self):
38+
with raises(TypeError):
39+
to_unicode(True)
40+
41+
2242
class UnicodeToStrTestCase(TestCase):
2343

2444
def test_deprecation(self):

0 commit comments

Comments
 (0)