def test_non_digit(self): try: interpolate('*.this.is.*.simply.a.test', '6.this.is.not.correct') except ValueError as exception: self.assertEqual(str(exception), "Can't interpolate * with non-digit value 'not'.") return self.fail("Did not raise ValueError on path mismatch.")
def test_mismatch_paths(self): try: interpolate('*.this.is.*.simply.a.test', '6.this.is.666.not.correct') except ValueError as exception: self.assertEqual( str(exception), "Can't interpolate *.this.is.*.simply.a.test with 6.this.is.666.not.correct, because paths differ at simply/not." ) return self.fail("Did not raise ValueError on path mismatch.")
def test_longer_source(self): result = interpolate('*.this.is.*.simply.a.test', '6.this.is.3.simply.a.test.8.5.longer.3.is.ignored') self.assertEqual(result, '6.this.is.3.simply.a.test')
def test_shorter_source(self): result = interpolate('*.this.is.*.simply.a.test', '6.this.is.3') self.assertEqual(result, '6.this.is.3.simply.a.test')
def test_multi_interpolation(self): result = interpolate('*.this.is.*.simply.*.test', '6.this.is.3.simply.1.test') self.assertEqual(result, '6.this.is.3.simply.1.test')
def test_single_interpolation(self): result = interpolate('*', '8') self.assertEqual(result, '8')