Beispiel #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')
Beispiel #2
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')
Beispiel #3
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()))
Beispiel #4
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()))
Beispiel #5
0
 def test_escaped_interpolation(self):
     self.assertEqual(interpolate('$${foo}', bddict(foo='hi')), '${foo}')
Beispiel #6
0
 def test_unset_value(self):
     self.assertEqual(interpolate('${foo}', bddict()), '')
Beispiel #7
0
 def test_empty_value(self):
     self.assertEqual(interpolate('${foo}', bddict(foo='')), '')
Beispiel #8
0
 def test_escaped_interpolation(self):
     self.assertEqual(interpolate('$${foo}', bddict(foo='hi')), '${foo}')
Beispiel #9
0
 def test_unset_value(self):
     self.assertEqual(interpolate('${foo}', bddict()), '')
Beispiel #10
0
 def test_empty_value(self):
     self.assertEqual(interpolate('${foo}', bddict(foo='')), '')