コード例 #1
0
    def test_basic(self):
        """Test whether a normal string modulo operation works as it should"""
        s = "That's a %s test of with some %% symbols in it"
        self.assertEqual(docrep.safe_modulo(s, 'simple'), s % 'simple')

        s = "That's another %(simple)s test with some %% in it"
        self.assertEqual(docrep.safe_modulo(s, {'simple': 'simple'}),
                         s % {'simple': 'simple'})
コード例 #2
0
 def test_incomplete_format(self):
     ref = "That's a basic test of with missing format for %(symbols)"
     with self.assertRaises(ValueError):
         docrep.safe_modulo(ref, {'symbols': 'test'})
コード例 #3
0
 def test_missing_kwarg_and_arg(self):
     """Test whether it works if we have another % argument in it"""
     s = "That's a %(basic)s test of with missing %(symbols)s and % in it"
     ref = "That's a basic test of with missing %(symbols)s and % in it"
     with self.assertWarns(SyntaxWarning):
         self.assertEqual(docrep.safe_modulo(s, {'basic': 'basic'}), ref)
コード例 #4
0
 def test_missing_arg(self):
     """Test whether it works if we have another % argument in it"""
     s = "That's a %(basic)s test of with additional % and %s in it"
     ref = "That's a basic test of with additional % and %s in it"
     self.assertEqual(docrep.safe_modulo(s, {'basic': 'basic'}), ref)