Ejemplo n.º 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)
Ejemplo n.º 2
0
 def test_arg__some_object(self):
     self.assertFalse(__unit__.is_tuple(object()))
Ejemplo n.º 3
0
 def test_arg__none(self):
     self.assertFalse(__unit__.is_tuple(None))
Ejemplo n.º 4
0
 def _assertTuple(self, obj):
     self.assertTrue(is_tuple(obj), msg="%r is not a tuple" % (obj,))
Ejemplo n.º 5
0
 def _assertTuple(self, obj):
     self.assertTrue(is_tuple(obj), msg="%r is not a tuple" % (obj, ))
Ejemplo n.º 6
0
 def test_len__negative(self):
     with self.assertRaises(ValueError):
         __unit__.is_tuple(self.TUPLE, len_=-1)
Ejemplo n.º 7
0
 def test_len__string(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_="42")
Ejemplo n.º 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))
Ejemplo n.º 9
0
 def test_len__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_=object())
Ejemplo n.º 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))
Ejemplo n.º 11
0
 def test_arg__nonempty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.TUPLE))
Ejemplo n.º 12
0
 def test__arg__empty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE))
Ejemplo n.º 13
0
 def test_arg__some_object(self):
     self.assertFalse(__unit__.is_tuple(object()))
Ejemplo n.º 14
0
 def test_arg__none(self):
     self.assertFalse(__unit__.is_tuple(None))
Ejemplo n.º 15
0
 def test__arg__empty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.EMPTY_TUPLE))
Ejemplo n.º 16
0
 def test_arg__nonempty_tuple(self):
     self.assertTrue(__unit__.is_tuple(self.TUPLE))
Ejemplo n.º 17
0
 def test_len__string(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_="42")
Ejemplo n.º 18
0
 def test_len__some_object(self):
     with self.assertRaises(TypeError):
         __unit__.is_tuple(self.TUPLE, len_=object())
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 21
0
 def test_len__negative(self):
     with self.assertRaises(ValueError):
         __unit__.is_tuple(self.TUPLE, len_=-1)
Ejemplo n.º 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))
Ejemplo n.º 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))