def test_format(self): expectation = '2 ** 10 = 1024' reality = LazyFormat('{two} ** {ten} = {result}') reality = reality.format(two=2, ten=10, result=2**10) self.assertEqual(expectation, reality, 'Format method doesn\'t work properly')
def test_example(self): project = LazyFormat('{name} {0}.{1}.{2} {year} {author}') self.assertEqual(project, '{name} {0}.{1}.{2} {year} {author}') project = LazyFormat('{name} {0}.{1}.{2} {year} {author}', 0, 0, 1, year=2013) self.assertEqual(project, '{name} 0.0.1 2013 {author}') project = LazyFormat('{name} {0}.{1}.{2} {year} {author!s}', 1, 0, year=2013) self.assertEqual(project.format(9, name='lazy format', author='miph'), 'lazy format 1.0.9 2013 miph')
def test_format(self): expectation = '2 ** 10 = 1024' reality = LazyFormat('{two} ** {ten} = {result}') reality = reality.format(two=2, ten=10, result=2 ** 10) self.assertEqual(expectation, reality, 'Format method doesn\'t work properly')