-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_compat.py
More file actions
38 lines (27 loc) · 928 Bytes
/
test_compat.py
File metadata and controls
38 lines (27 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from unittest import TestCase
from stackify.compat import b
from stackify.compat import iterkeys
from stackify.compat import iteritems
class CompatTest(TestCase):
def setUp(self):
self.dict_data = {
"key1": "value1",
"key2": "value2"
}
self.list_data = ["foo", "bar"]
def test_convert_string_to_byte(self):
byte = '1'
value = b(byte)
assert isinstance(value, bytes)
def test_iterkeys_should_return_iterator(self):
iter_keys = iterkeys(self.dict_data)
self.assert_instance_is_an_iterator(iter_keys)
def test_iteritems_should_return_iterator(self):
iter_items = iteritems(self.dict_data)
self.assert_instance_is_an_iterator(iter_items)
def assert_instance_is_an_iterator(self, item):
try:
iter(item)
assert True
except Exception:
assert False