def test_bad_type(self): """Test non string arguments.""" with self.assertRaises(TypeError): self.assertFalse(ishex(0xff)) with self.assertRaises(TypeError): self.assertFalse(ishex(True))
def test_hex_literal(self): """Test hex literal. It uses non-hex char - 'x'.""" self.assertFalse(ishex('0xff'))
def test_empty(self): """Test empty string.""" self.assertTrue(ishex(''))
def test_failing(self): """Test non-hexes.""" self.assertFalse(ishex('g')) self.assertFalse(ishex('5x'))
def test_good(self): """Test actual hexes.""" self.assertTrue(ishex('1')) self.assertTrue(ishex('a')) self.assertTrue(ishex('5b')) self.assertTrue(ishex('1234567890abcdef'))