def __init__(self, number_str): try: number = int(number_str) if number < 0: raise ValueError('Input error: wrong format') self.__number_str = number_str self.lcd_numbers = [LcdSymbol(symbol) for symbol in number_str] except ValueError: raise ValueError('Input error: wrong format')
def test_can_create(self): lcd_symbol_instance = LcdSymbol('0') self.assertTrue(isinstance(lcd_symbol_instance, LcdSymbol))
def test_not_equal(self): lcd_symbol_instance = LcdSymbol('3') other_instance = LcdSymbol('4') self.assertFalse(lcd_symbol_instance.equals(other_instance))
def test_equal(self): lcd_symbol_instance = LcdSymbol('2') other_instance = LcdSymbol('2') self.assertTrue(lcd_symbol_instance.equals(other_instance))
def test_equal_wrong_type_error(self): lcd_symbol_instance = LcdSymbol('0') other_instance = 't' with self.assertRaises(TypeError): lcd_symbol_instance.equals(other_instance)
def test_cant_create_with_invalid_character_neg(self): with self.assertRaises(ValueError): LcdSymbol('-1')
def test_cant_create_from_empty_str(self): with self.assertRaises(ValueError): LcdSymbol('')