class PythonFormatCheckTest(CheckTestCase): check = PythonFormatCheck() def setUp(self): super(PythonFormatCheckTest, self).setUp() self.test_highlight = ( 'python-format', '%sstring%d', [(0, 2, u'%s'), (8, 10, u'%d')], ) def test_no_format(self): self.assertFalse(self.check.check_format('strins', 'string', False)) def test_format(self): self.assertFalse( self.check.check_format('%s string', '%s string', False)) def test_percent_format(self): self.assertFalse( self.check.check_format('%d%% string', '%d%% string', False)) def test_named_format(self): self.assertFalse( self.check.check_format('%(name)s string', '%(name)s string', False)) def test_missing_format(self): self.assertTrue(self.check.check_format('%s string', 'string', False)) def test_missing_named_format(self): self.assertTrue( self.check.check_format('%(name)s string', 'string', False)) def test_missing_named_format_ignore(self): self.assertFalse( self.check.check_format('%(name)s string', 'string', True)) def test_wrong_format(self): self.assertTrue( self.check.check_format('%s string', '%c string', False)) def test_reordered_format(self): self.assertTrue( self.check.check_format('%s %d string', '%d %s string', False)) def test_wrong_named_format(self): self.assertTrue( self.check.check_format('%(name)s string', '%(jmeno)s string', False)) def test_reordered_named_format(self): self.assertFalse( self.check.check_format('%(name)s %(foo)s string', '%(foo)s %(name)s string', False)) def test_reordered_named_format_long(self): self.assertFalse( self.check.check_format( '%(count)d strings into %(languages)d languages %(percent)d%%', '%(languages)d dil içinde %(count)d satır %%%(percent)d', False))
def setUp(self): self.check = PythonFormatCheck()