예제 #1
0
class PythonFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PythonFormatCheck()

    def test_no_format(self):
        self.assertFalse(
            self.check.check_format('strins', 'string',
                                    Unit('python_no_format'), 0, False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format(u'%s string', u'%s string',
                                    Unit('python_format'), 0, False))

    def test_percent_format(self):
        self.assertFalse(
            self.check.check_format(u'%d%% string', u'%d%% string',
                                    Unit('python_percent_format'), 0, False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format(u'%(name)s string', u'%(name)s string',
                                    Unit('python_named_format'), 0, False))

    def test_missing_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'string',
                                    Unit('python_missing_format'), 0, False))

    def test_missing_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%(name)s string', u'string',
                                    Unit('python_missing_named_format'), 0,
                                    False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(
            self.check.check_format(u'%(name)s string', u'string',
                                    Unit('python_missing_named_format'), 0,
                                    True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'%c string',
                                    Unit('python_wrong_format'), 0, False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%(name)s string', u'%(jmeno)s string',
                                    Unit('python_wrong_named_format'), 0,
                                    False))
예제 #2
0
 def setUp(self):
     self.check = PythonFormatCheck()
예제 #3
0
class PythonFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PythonFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            MockUnit('python_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            MockUnit('python_format'),
            0,
            False
        ))

    def test_percent_format(self):
        self.assertFalse(self.check.check_format(
            u'%d%% string',
            u'%d%% string',
            MockUnit('python_percent_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%(name)s string',
            u'%(name)s string',
            MockUnit('python_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            MockUnit('python_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%(name)s string',
            u'string',
            MockUnit('python_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%(name)s string',
            u'string',
            MockUnit('python_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            MockUnit('python_wrong_format'),
            0,
            False
        ))

    def test_reordered_format(self):
        self.assertTrue(self.check.check_format(
            u'%s %d string',
            u'%d %s string',
            MockUnit('python_wrong_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%(name)s string',
            u'%(jmeno)s string',
            MockUnit('python_wrong_named_format'),
            0,
            False
        ))

    def test_reordered_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%(name)s %(foo)s string',
            u'%(foo)s %(name)s string',
            MockUnit('python_reordered_named_format'),
            0,
            False
        ))

    def test_reordered_named_format_long(self):
        self.assertFalse(self.check.check_format(
            u'%(count)d strings into %(languages)d languages %(percent)d%%',
            u'%(languages)d dil içinde %(count)d satır %%%(percent)d',
            MockUnit('python_reordered_named_format_long'),
            0,
            False
        ))
예제 #4
0
 def setUp(self):
     self.check = PythonFormatCheck()
예제 #5
0
class PythonFormatCheckTest(TestCase):
    def setUp(self):
        self.check = PythonFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            Unit('python_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            Unit('python_format'),
            0,
            False
        ))

    def test_percent_format(self):
        self.assertFalse(self.check.check_format(
            u'%d%% string',
            u'%d%% string',
            Unit('python_percent_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%(name)s string',
            u'%(name)s string',
            Unit('python_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            Unit('python_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%(name)s string',
            u'string',
            Unit('python_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%(name)s string',
            u'string',
            Unit('python_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            Unit('python_wrong_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%(name)s string',
            u'%(jmeno)s string',
            Unit('python_wrong_named_format'),
            0,
            False
        ))