18
18
#-----------------------------------------------------------------------------
19
19
20
20
def make_testlists ():
21
+ """ setup some data for the conversion Tests
22
+ eg lislist_to_listset"""
21
23
listlist = [[0 ,1 ,2 ],[3 ,4 ,5 ],[6 ,7 ,8 ,9 ]]
22
24
dictset = {val :set (item ) for val , item in enumerate (listlist )}
23
25
listset = [set (item ) for item in listlist ]
@@ -28,6 +30,7 @@ def test_dictset_to_listset():
28
30
new_list_set = util .dictset_to_listset (dictset )
29
31
npt .assert_equal (new_list_set , listset )
30
32
with npt .assert_raises (ValueError ):
33
+ # catch bad type
31
34
tmp = util .dictset_to_listset (listset )
32
35
33
36
def test_listset_to_dictset ():
@@ -41,13 +44,21 @@ def test_listset_to_dictset():
41
44
def test_no_repeats_in_listlist ():
42
45
jnk = [[0 ,1 ,2 ],[3 ,4 ,5 ]] # all unique
43
46
nt .assert_true (util ._no_repeats_in_listlist (jnk ))
44
- jnk = [[0 ,1 ,2 ], [0 ,1 ,2 ]]
47
+ jnk = [[0 ,1 ,2 ], [0 ,1 ,2 ]] # repeats
45
48
nt .assert_false (util ._no_repeats_in_listlist (jnk ))
46
49
with npt .assert_raises (ValueError ):
47
50
util ._no_repeats_in_listlist ({0 :0 })
48
51
with npt .assert_raises (ValueError ):
49
52
util ._no_repeats_in_listlist ([set ([0 ,1 ,2 ])])
50
53
54
+ def test_contains_only ():
55
+ listlist , listset , dictset = make_testlists ()
56
+ nt .assert_true (util ._contains_only (listlist , list ))
57
+ nt .assert_true (util ._contains_only (listset , set ))
58
+ nt .assert_true (util ._contains_only (dictset , set ))
59
+ nt .assert_false (util ._contains_only ([1 ,2 ,3 ], set ))
60
+
61
+
51
62
def test_listlist_to_listset ():
52
63
listlist , listset , _ = make_testlists ()
53
64
new_listset = util .listlist_to_listset (listlist )
0 commit comments