def test_documentation(): assert roman("II") == 2 assert roman("IV") == 4 assert roman("IX") == 9 assert roman("XIX") == 19 assert roman("XX") == 20 assert roman("MDCCLXXVI") == 1776 assert roman("MMXIX") == 2019
def test_four_nine_numbers(): assert roman('XLIX') == 49 assert roman('XL') == 40 assert roman('XCIX') == 99 assert roman('XC') == 90 assert roman('XCIV') == 94 assert roman('CDXCIX') == 499 assert roman('CMXCIX') == 999
def test_up_to_ten(): assert roman('I') == 1 assert roman('III') == 3 assert roman('V') == 5 assert roman('VI') == 6 assert roman('VII') == 7 assert roman('VIII') == 8 assert roman('X') == 10
def test_single_characters(): assert roman("I") == 1 assert roman("V") == 5 assert roman("X") == 10 assert roman("L") == 50 assert roman("C") == 100 assert roman("M") == 1000
from roman import roman assert roman(1) == 'I' assert roman(4) == 'IV' # and not 'IIII' assert roman(5) == 'V' assert roman(9) == 'IX' assert roman(10) == 'X' # and not VV
def converts1(self): eq_(roman(1), 'I')
def test_roundtrip_XLIX(): assert_equals(roman(arabic('XLIX')), 'XLIX')
def test_one(self): self.assertEqual(roman(1), 'I')
def test_twenty(self): self.assertEquals("XX", roman(20))
def test_ninety(self): self.assertEquals("XC", roman(90))
def test_roman_49(): assert_equals(roman(49), 'XLIX')
def test_roman_50(): assert_equals(roman(50), 'L')
def test_roman_44(): assert_equals(roman(44), 'XLIV')
def test_roman_99(): assert_equals(roman(99), 'XCIX')
def test_roman_9(): assert_equals(roman(9), "IX")
def test_roman_4(): assert_equals(roman(4), "IV")
def test_roman_1510(): assert_equals(roman(1510), "MDX")
def test_roman_0(): assert_equals(roman(0), "")
def test_roman_34(): assert_equals(roman(34), 'XXXIV')
def test_four(self): self.assertEquals("IV", roman(4))
def test_roman_39(): assert_equals(roman(39), 'XXXIX')
def test_fourteen(self): self.assertEquals("XIV", roman(14))
def test_roman_1999(): assert_equals(roman(1999), 'MCMXCIX')
def test_fifty(self): self.assertEquals("L", roman(50))
def test_roman_1499(): assert_equals(roman(1499), 'MCDXCIX')
def test_two_hundred(self): self.assertEquals("CC", roman(200))
def test_roundtrip(): assert_equals(arabic(roman(1)), 1)
def make_item(bonus_count = 4, level = 0): col = random.randint(0,len(column_type_name)-1) row = random.randint(0,7) effect_number = random.randint(0,len(Effect)-1) name = column_type_name[col] if(bonus_count > 4): name = Effect[effect_number] + " " + column_type_name[col] negatives = 1 item_unit = None if(bonus_count > 4): attr = Effect_Attrib[Effect[effect_number]] item_unit = Ability(bonus_count-1,negatives,(name,effect_number),force_power=attr).unit else: item_unit = Ability(bonus_count,negatives,(name,effect_number)).unit item_unit.level_up(level) item_unit.clear_bonus() bonus_count = item_unit.attrib_count() unit_title_name = (item_unit.output_attribs()).split("\n",1) string_to_print = "" if(len(unit_title_name)>1): unit_title_name = "".join(re.split("\(|\)",unit_title_name[1])[0::2]) if(bonus_count > 2): attr = item_unit.random_attrib() if((col == 19 or col == 20)): name = name[:-6]+random.choice(("cuirass", "plate", "outfit")) if(attr == "armour" or attr == "dodge_chance"): name += random.choice((" of Protection"," of Defense"," of Defiance")) else: name += " of " + attr else: name = random.choice(("Worn", "Old", "Musty", "Bent", "Cracked"))+" "+name name = name.replace("_"," ").title() if(level > 0): name += " " + str(roman(level)) string_to_print = (name+"\n"+unit_title_name.replace("_"," ").title()) else: name = name.title() if(level > 0): name += " " + str(roman(level)) string_to_print = name icon = globals.icons_items.image_by_coords(60,col,row) icon.blit(globals.icons_items_outlines, (0,0), (60*(3-(bonus_count+1)/2), 0, 60, 60)) icon.blit(globals.icons_items_outlines, (2,2), (60*(3-(bonus_count+1)/2), 0, 60, 60)) icon.blit(globals.icons_items_outlines, (-2,-2), (60*(3-(bonus_count+1)/2), 0, 60, 60)) icon.blit(globals.icons_items_outlines, (-2,2), (60*(3-(bonus_count+1)/2), 0, 60, 60)) icon.blit(globals.icons_items_outlines, (2,-2), (60*(3-(bonus_count+1)/2), 0, 60, 60)) icon.convert() #pygame.image.save(icon,"Saved Games/0/Items/"+name+".png") #write_file("Saved Games/0/Items/"+name+".pkl",item_unit) ret = (name, item_unit, icon, item_unit.attrib_count(), int(max(max(item_unit.m_level,0.5) * item_unit.attrib_count() * item_unit.attrib_count() * 10, 13)*random.uniform(0.7,1.3)), string_to_print) #has to be reset for the next item bonus_count = 4 return ret
def test_roman_1(): assert_equals(roman(1), 'I')
def test_two(self): self.assertEqual(roman(2), 'II')
def converts6(self): eq_(roman(6), 'VI')
import sys from roman import roman if __name__ == '__main__': print(roman('II')) # 2 print(roman('IV')) # 4 print(roman('IX')) # 9 print(roman('XIX')) # 19 print(roman('XX')) # 20 print(roman('MDCCLXXVI')) # 1776 print(roman('MMXIX')) # 2019
def test_two(self): self.assertEquals("II", roman(2))
def converts2(self): eq_(roman(2), 'II')
def test_roman_110(): assert_equals(roman(110), 'CX')
def test_converts(self, arabic, expected_roman): eq_(roman(arabic), expected_roman)
def test_six(self): self.assertEquals("VI", roman(6))
def test_three(self): self.assertEquals("III", roman(3))
def test_nine(self): self.assertEquals("IX", roman(9))
def test_five(self): self.assertEquals("V", roman(5))
def test_roman_10(): assert_equals(roman(10), 'X')
def test_seven(self): self.assertEquals("VII", roman(7))
def test_19(): assert roman("XIX") == 19
def test_ten(self): self.assertEquals("X", roman(10))
def test_20(): assert roman("XX") == 20
def test_nineteen(self): self.assertEquals("XIX", roman(19))
def test_1776(): assert roman("MDCCLXXVI") == 1776
def test_fourty(self): self.assertEquals("XL", roman(40))
def test_2019(): assert roman("MMXIX") == 2019
def test_zero(self): self.assertEquals("", roman(0))
def test_3_in_row(): assert roman("CXXX") == 130
def test_one_hundred(self): self.assertEquals("C", roman(100))
def test_8(): assert roman("VIII") == 8
def test_one(self): self.assertEquals("I", roman(1))
def test_roman_5(): assert_equals(roman(5), 'V')