Example #1
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

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

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

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

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

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

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

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

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%10s string', u'%20s string',
                                    Unit('c_wrong_named_format'), 0, False))
Example #2
0
 def setUp(self):
     self.check = CFormatCheck()
Example #3
0
 def setUp(self):
     self.check = CFormatCheck()
Example #4
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

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

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

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

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

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

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

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

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%10s string',
            u'%20s string',
            MockUnit('c_wrong_named_format'),
            0,
            False
        ))