Skip to content

Instantly share code, notes, and snippets.

@gcollic
Created May 24, 2013 08:31
Show Gist options
  • Save gcollic/5642119 to your computer and use it in GitHub Desktop.
Save gcollic/5642119 to your computer and use it in GitHub Desktop.
Tests of the Roman Numerals kata in python (Coding Dojo of Beaulieu 22/05/2013)
import unittest
from kata import roman
l = [
["I", 1],
["II", 2],
["III", 3],
["IV", 4],
["V", 5],
["IX", 9],
["X", 10],
["XIV", 14],
["XX", 20],
["XXX", 30],
["XLII", 42],
["XLIX", 49],
["L", 50],
["LX", 60],
["LXVII", 67],
["XC", 90],
["XCI", 91],
["XCIX", 99],
["C", 100],
["CVII", 107],
["CCCXCIX", 399],
["CD", 400],
["CDXCIX", 499],
["D", 500],
["DCXLVII", 647],
["DCCCLXXXVIII", 888],
["CM", 900],
["CMI", 901],
["CMXCIX", 999],
["M", 1000],
["MCMXCIX", 1999],
["MMMMDCCCLXXXVIII", 4888],
]
class TestSequense(unittest.TestCase):
pass
def int_to_roman_test_generator(a, b):
def test(self):
self.assertEqual(a, roman(b))
return test
for t in l:
test_name = 'test_{}'.format(t[1])
test = int_to_roman_test_generator(t[0], t[1])
setattr(TestSequense, test_name, test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment