Пример #1
0
def _harmonize_subset_types(set_, subset_tuples):
    """Possibly convert an iterable of tuples with subsets of given "set",
    to an iterable of :class:`set` objects if original "set" was so too.
    """
    # if argument is originally a set, return subsets also as sets;
    # otherwise (for non-set collection), return subsets as tuples
    if is_tuple(set_):
        return subset_tuples
    else:
        subset_class = set_.__class__ if is_set(set_) else tuple
        return imap(subset_class, subset_tuples)
Пример #2
0
 def test_arg__some_object(self):
     self.assertFalse(__unit__.is_tuple(object()))
Пример #3
0
 def test_arg__none(self):
     self.assertFalse(__unit__.is_tuple(None))
Пример #4
0
 def _assertTuple(self, obj):
     self.assertTrue(is_tuple(obj), msg="%r is not a tuple" % (obj,))
Пример #5
0
 def _assertTuple(self, obj):
     self.assertTrue(is_tuple(obj), msg="%r is not a tuple" % (obj, ))
Пример #6
0
 def test_len__negative(self):
     with self.assertRaises(ValueError):
         __unit__.is_tuple(self.TUPLE, len_=-1)
Пример #7
0
 def test_len__string(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_="42")
Пример #8
0
 def test_len__none(self):
     self.assertFalse(__unit__.is_tuple(None, len_=None))
     self.assertFalse(__unit__.is_tuple(object()))
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE, len_=None))
     self.assertTrue(__unit__.is_tuple(self.TUPLE, len_=None))
Пример #9
0
 def test_len__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_=object())
Пример #10
0
 def test_len__none(self):
     self.assertFalse(__unit__.is_tuple(None, len_=None))
     self.assertFalse(__unit__.is_tuple(object()))
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE, len_=None))
     self.assertTrue(__unit__.is_tuple(self.TUPLE, len_=None))
Пример #11
0
 def test_arg__nonempty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.TUPLE))
Пример #12
0
 def test__arg__empty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE))
Пример #13
0
 def test_arg__some_object(self):
     self.assertFalse(__unit__.is_tuple(object()))
Пример #14
0
 def test_arg__none(self):
     self.assertFalse(__unit__.is_tuple(None))
Пример #15
0
 def test__arg__empty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE))
Пример #16
0
 def test_arg__nonempty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.TUPLE))
Пример #17
0
 def test_len__string(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_="42")
Пример #18
0
 def test_len__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_=object())
Пример #19
0
 def test_len__zero(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE, len_=0))
     self.assertFalse(__unit__.is_tuple(self.TUPLE, len_=0))
Пример #20
0
 def test_len__zero(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE, len_=0))
     self.assertFalse(__unit__.is_tuple(self.TUPLE, len_=0))
Пример #21
0
 def test_len__negative(self):
     with self.assertRaises(ValueError):
         __unit__.is_tuple(self.TUPLE, len_=-1)
Пример #22
0
 def test_len__positive(self):
     self.assertFalse(
         __unit__.is_tuple(self.EMPTY_TUPLE, len_=self.TUPLE_SIZE))
     self.assertTrue(__unit__.is_tuple(self.TUPLE, len_=self.TUPLE_SIZE))
     self.assertFalse(
         __unit__.is_tuple(self.TUPLE, len_=self.TUPLE_SIZE + 1))
Пример #23
0
 def test_len__positive(self):
     self.assertFalse(
         __unit__.is_tuple(self.EMPTY_TUPLE, len_=self.TUPLE_SIZE))
     self.assertTrue(__unit__.is_tuple(self.TUPLE, len_=self.TUPLE_SIZE))
     self.assertFalse(
         __unit__.is_tuple(self.TUPLE, len_=self.TUPLE_SIZE + 1))