Ejemplo n.º 1
0
 def testExtend(self):
     """MultiValue: Extending a list converts all to required type"""
     multival = MultiValue(IS, [1, 5, 10])
     multival.extend(['7', 42])
     assert isinstance(multival[-2], IS)
     assert isinstance(multival[-1], IS)
     assert 7 == multival[-2]
Ejemplo n.º 2
0
 def testExtend(self):
     """MultiValue: Extending a list converts all to required type"""
     multival = MultiValue(IS, [1, 5, 10])
     multival.extend(['7', 42])
     self.assertTrue(isinstance(multival[-2], IS))
     self.assertTrue(isinstance(multival[-1], IS))
     self.assertEqual(multival[-2], 7, "Item set by extend not correct value")
Ejemplo n.º 3
0
 def testExtend(self):
     """MultiValue: Extending a list converts all to required type"""
     multival = MultiValue(IS, [1, 5, 10])
     multival.extend(['7', 42])
     self.assertTrue(isinstance(multival[-2], IS))
     self.assertTrue(isinstance(multival[-1], IS))
     self.assertEqual(multival[-2], 7, "Item set by extend not correct value")
 def test_str_rep(self):
     """MultiValue: test print output"""
     multival = MultiValue(IS, [])
     assert '' == str(multival)
     multival.extend(['1', 2, 3, 4])
     assert "[1, 2, 3, 4]" == str(multival)
     multival = MultiValue(str, [1, 2, 3])
     assert "['1', '2', '3']" == str(multival)
     multival = MultiValue(int, [1, 2, 3])
     assert '[1, 2, 3]' == str(multival)
     multival = MultiValue(float, [1.1, 2.2, 3.3])
     assert '[1.1, 2.2, 3.3]' == str(multival)
     mv = MultiValue(IS, [])
     mv._list = ['1234', b'\x01\x00']
     assert "['1234', b'\\x01\\x00']" == str(mv)