22# This program is distributed under the MIT license.
33
44from python_toolbox import cute_testing
5+ from python_toolbox import sequence_tools
56
67from python_toolbox .combi import *
78
@@ -39,15 +40,45 @@ def test():
3940 with cute_testing .RaiseAssertor (IndexError ):
4041 product_space [- product_space .length - 100 ]
4142
42- assert {ProductSpace ((range (4 ), range (3 ))),
43- ProductSpace ((range (4 ), range (3 ))),
44- ProductSpace ((range (3 ), range (4 )))} == {
45- ProductSpace ((range (4 ), range (3 ))),
46- ProductSpace ((range (3 ), range (4 )))
47- }
43+ # In the following asserts, using `CuteRange` rather than `xrange` because
44+ # the latter doesn't have a functional `__hash__`.
4845
49- assert ProductSpace ((range (4 ), range (3 ))) == \
50- ProductSpace ((range (4 ), range (3 )))
51- assert ProductSpace ((range (4 ), range (3 ))) != \
52- ProductSpace ((range (3 ), range (4 )))
46+ assert {
47+ ProductSpace (
48+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
49+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))
50+ ),
51+ ProductSpace (
52+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
53+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))
54+ ),
55+ ProductSpace (
56+ (sequence_tools .CuteRange (3 , _avoid_built_in_range = True ),
57+ sequence_tools .CuteRange (4 , _avoid_built_in_range = True ))
58+ )} == {
59+ ProductSpace (
60+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
61+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))
62+ ),
63+ ProductSpace (
64+ (sequence_tools .CuteRange (3 , _avoid_built_in_range = True ),
65+ sequence_tools .CuteRange (4 , _avoid_built_in_range = True ))
66+ )
67+ }
68+
69+ assert ProductSpace (
70+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
71+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))
72+ ) == ProductSpace (
73+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
74+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))
75+ )
76+
77+ assert ProductSpace (
78+ (sequence_tools .CuteRange (4 , _avoid_built_in_range = True ),
79+ sequence_tools .CuteRange (3 , _avoid_built_in_range = True ))) != \
80+ ProductSpace (
81+ (sequence_tools .CuteRange (3 , _avoid_built_in_range = True ),
82+ sequence_tools .CuteRange (4 , _avoid_built_in_range = True ))
83+ )
5384
0 commit comments