def test_malformed_antecedents(): '''from_roman should fail with malformed antecedents''' for s in ('IIMXCC', 'VX', 'DCM', 'CMM', 'IXIV', 'MCMC', 'XCX', 'IVI', 'LM', 'LD', 'LC'): #raise InvalidRomanNumeralError('fail with malformed antecedents', s) with pytest.raises(InvalidRomanNumeralError): from_roman(s)
def test_Blank(): '''from_roman should fail with blank string''' s = '' with pytest.raises(InvalidRomanNumeralError): from_roman(s)
def test_repeated_pairs(): '''from_roman should fail with repeated pairs of numerals''' for s in ('CMCM', 'CDCD', 'XCXC', 'XLXL', 'IXIX', 'IVIV'): #raise InvalidRomanNumeralError('repeated pairs of numerals', s) with pytest.raises(InvalidRomanNumeralError): from_roman(s)
def test_too_many_repeated_numerals(): '''from_roman should fail with too many repeated numerals''' for s in ('MMMMM', 'DD', 'CCCC', 'LL', 'XXXX', 'VV', 'IIII'): with pytest.raises(InvalidRomanNumeralError): from_roman(s)
def test_from_roman_known_values(integer, roman): 'testuje fci from_roman' assert from_roman(roman) == integer
def test_roundtrip(): for integer in range(1, 5000): roman = to_roman(integer) result = from_roman(roman) assert integer == result