Exemplo n.º 1
0
    def test_valid_interpolations(self):
        self.assertEqual(interpolate('$foo', bddict(foo='hi')), 'hi')
        self.assertEqual(interpolate('${foo}', bddict(foo='hi')), 'hi')

        self.assertEqual(interpolate('${subject} love you', bddict(subject='i')), 'i love you')
        self.assertEqual(interpolate('i ${verb} you', bddict(verb='love')), 'i love you')
        self.assertEqual(interpolate('i love ${object}', bddict(object='you')), 'i love you')
Exemplo n.º 2
0
 def test_invalid_strings(self):
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('$}', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${}', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${ }', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${ foo}', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${foo }', bddict()))
     self.assertRaises(InvalidInterpolation, lambda: interpolate('${foo!}', bddict()))
Exemplo n.º 3
0
 def test_unset_value(self):
     self.assertEqual(interpolate('${foo}', bddict()), '')
Exemplo n.º 4
0
 def test_escaped_interpolation(self):
     self.assertEqual(interpolate('$${foo}', bddict(foo='hi')), '${foo}')
Exemplo n.º 5
0
 def test_empty_value(self):
     self.assertEqual(interpolate('${foo}', bddict(foo='')), '')