Lines Matching refs:bool

1 # Test properties of bool promised by PEP 285
12 class C(bool):
17 self.fail("bool should not be subclassable")
19 self.assertRaises(TypeError, int.__new__, bool, 0)
104 self.assertIsNot(b**i, bool(int(b)**i))
108 self.assertIs(a&b, bool(int(a)&int(b)))
109 self.assertIs(a|b, bool(int(a)|int(b)))
110 self.assertIs(a^b, bool(int(a)^int(b)))
112 self.assertIsNot(a&int(b), bool(int(a)&int(b)))
114 self.assertIsNot(a|int(b), bool(int(a)|int(b)))
116 self.assertIsNot(a^int(b), bool(int(a)^int(b)))
118 self.assertIsNot(int(a)&b, bool(int(a)&int(b)))
120 self.assertIsNot(int(a)|b, bool(int(a)|int(b)))
122 self.assertIsNot(int(a)^b, bool(int(a)^int(b)))
159 self.assertRaises(TypeError, bool, 42, 42)
160 self.assertIs(bool(10), True)
161 self.assertIs(bool(1), True)
162 self.assertIs(bool(-1), True)
163 self.assertIs(bool(0), False)
164 self.assertIs(bool("hello"), True)
165 self.assertIs(bool(""), False)
166 self.assertIs(bool(), False)
170 bool(x=10)
187 self.assertIs(isinstance(True, bool), True)
188 self.assertIs(isinstance(False, bool), True)
191 self.assertIs(isinstance(1, bool), False)
192 self.assertIs(isinstance(0, bool), False)
195 self.assertIs(issubclass(bool, int), True)
196 self.assertIs(issubclass(int, bool), False)
230 self.assertNotIsInstance(True & 1, bool)
234 self.assertNotIsInstance(True | 1, bool)
238 self.assertNotIsInstance(True ^ 1, bool)
251 for t in [bool, complex, dict, float, int, list, object,
253 self.assertIs(bool(t), True)
293 # from __bool__(). This isn't really a bool test, but
295 check = lambda o: self.assertRaises(TypeError, bool, o)
311 # __bool__() must return a bool not an int
320 self.assertRaises(ValueError, bool, Eggs())
323 self.assertIs(bool.from_bytes(b'\x00'*8, 'big'), False)
324 self.assertIs(bool.from_bytes(b'abcd', 'little'), True)
334 bool(A())
344 self.assertRaises(TypeError, bool, A())
350 self.assertRaises(TypeError, bool, B())
379 self.assertIs(bool.__new__(bool), False)
380 self.assertIs(bool.__new__(bool, 1), True)
381 self.assertIs(bool.__new__(bool, 0), False)
382 self.assertIs(bool.__new__(bool, False), False)
383 self.assertIs(bool.__new__(bool, True), True)