def setUp(self): self.check = Check() self.test_empty = ('', '', '') self.test_good_matching = ('string', 'string', '') self.test_good_none = ('string', 'string', '') self.test_good_ignore = None self.test_failure_1 = None self.test_failure_2 = None self.test_failure_3 = None self.test_ignore_check = ('x', 'x', self.check.ignore_string)
def setUp(self): self.check = Check() self.test_empty = ("", "", "") self.test_good_matching = ("string", "string", "") self.test_good_none = ("string", "string", "") self.test_good_ignore = None self.test_failure_1 = None self.test_failure_2 = None self.test_failure_3 = None
class CheckTestCase(TestCase): ''' Generic test, also serves for testing base class. ''' def setUp(self): self.check = Check() self.test_empty = ('', '', '') self.test_good_matching = ('string', 'string', '') self.test_good_none = ('string', 'string', '') self.test_good_ignore = None self.test_failure_1 = None self.test_failure_2 = None self.test_failure_3 = None self.test_ignore_check = ('x', 'x', self.check.ignore_string) def do_test(self, expected, data, lang='cs'): ''' Performs single check if we have data to test. ''' if data is None: return result = self.check.check_single( data[0], data[1], MockUnit(None, data[2], lang), 0 ) if expected: self.assertTrue( result, 'Check did not fire for "%s"/"%s" (%s)' % data ) else: self.assertFalse( result, 'Check did fire for "%s"/"%s" (%s)' % data ) def test_single_good_matching(self): self.do_test(False, self.test_good_matching) def test_single_good_none(self): self.do_test(False, self.test_good_none) def test_single_good_ignore(self): self.do_test(False, self.test_good_ignore) def test_single_empty(self): self.do_test(False, self.test_empty) def test_single_failure_1(self): self.do_test(True, self.test_failure_1) def test_single_failure_2(self): self.do_test(True, self.test_failure_2) def test_single_failure_3(self): self.do_test(True, self.test_failure_3) def test_check_good_matching_singular(self): self.assertFalse( self.check.check( [self.test_good_matching[0]], [self.test_good_matching[1]], MockUnit(None, self.test_good_matching[2]) ) ) def test_check_good_matching_plural(self): self.assertFalse( self.check.check( [self.test_good_matching[0]] * 2, [self.test_good_matching[1]] * 3, MockUnit(None, self.test_good_matching[2]) ) ) def test_check_failure_1_singular(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check( [self.test_failure_1[0]], [self.test_failure_1[1]], MockUnit(None, self.test_failure_1[2]) ) ) def test_check_failure_1_plural(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check( [self.test_failure_1[0]] * 2, [self.test_failure_1[1]] * 3, MockUnit(None, self.test_failure_1[2]) ) ) def test_check_ignore_check(self): self.assertFalse( self.check.check( [self.test_ignore_check[0]] * 2, [self.test_ignore_check[1]] * 3, MockUnit(None, self.test_ignore_check[2]) ) )
class CheckTestCase(TestCase): """ Generic test, also serves for testing base class. """ def setUp(self): self.check = Check() self.test_empty = ("", "", "") self.test_good_matching = ("string", "string", "") self.test_good_none = ("string", "string", "") self.test_good_ignore = None self.test_failure_1 = None self.test_failure_2 = None self.test_failure_3 = None def do_test(self, expected, data, lang="cs"): """ Performs single check if we have data to test. """ if data is None: return self.assertEqual(self.check.check_single(data[0], data[1], data[2], Language(lang), Unit(), 0), expected) def test_single_good_matching(self): self.do_test(False, self.test_good_matching) def test_single_good_none(self): self.do_test(False, self.test_good_none) def test_single_good_ignore(self): self.do_test(False, self.test_good_ignore) def test_single_empty(self): self.do_test(False, self.test_empty) def test_single_failure_1(self): self.do_test(True, self.test_failure_1) def test_single_failure_2(self): self.do_test(True, self.test_failure_2) def test_single_failure_3(self): self.do_test(True, self.test_failure_3) def test_check_good_matching_singular(self): self.assertFalse( self.check.check( [self.test_good_matching[0]], [self.test_good_matching[1]], self.test_good_matching[2], Language(), Unit(), ) ) def test_check_good_matching_plural(self): self.assertFalse( self.check.check( [self.test_good_matching[0]] * 2, [self.test_good_matching[1]] * 3, self.test_good_matching[2], Language(), Unit(), ) ) def test_check_failure_1_singular(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check( [self.test_failure_1[0]], [self.test_failure_1[1]], self.test_failure_1[2], Language(), Unit() ) ) def test_check_failure_1_plural(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check( [self.test_failure_1[0]] * 2, [self.test_failure_1[1]] * 3, self.test_failure_1[2], Language(), Unit() ) )
class CheckTestCase(TestCase): ''' Generic test, also serves for testing base class. ''' def setUp(self): self.check = Check() self.test_empty = ('', '', '') self.test_good_matching = ('string', 'string', '') self.test_good_none = ('string', 'string', '') self.test_good_ignore = None self.test_failure_1 = None self.test_failure_2 = None self.test_failure_3 = None self.test_ignore_check = ('x', 'x', self.check.ignore_string) def do_test(self, expected, data, lang='cs'): ''' Performs single check if we have data to test. ''' if data is None: return result = self.check.check_single(data[0], data[1], MockUnit(None, data[2], lang), 0) if expected: self.assertTrue(result, 'Check did not fire for "%s"/"%s" (%s)' % data) else: self.assertFalse(result, 'Check did fire for "%s"/"%s" (%s)' % data) def test_single_good_matching(self): self.do_test(False, self.test_good_matching) def test_single_good_none(self): self.do_test(False, self.test_good_none) def test_single_good_ignore(self): self.do_test(False, self.test_good_ignore) def test_single_empty(self): self.do_test(False, self.test_empty) def test_single_failure_1(self): self.do_test(True, self.test_failure_1) def test_single_failure_2(self): self.do_test(True, self.test_failure_2) def test_single_failure_3(self): self.do_test(True, self.test_failure_3) def test_check_good_matching_singular(self): self.assertFalse( self.check.check([self.test_good_matching[0]], [self.test_good_matching[1]], MockUnit(None, self.test_good_matching[2]))) def test_check_good_matching_plural(self): self.assertFalse( self.check.check([self.test_good_matching[0]] * 2, [self.test_good_matching[1]] * 3, MockUnit(None, self.test_good_matching[2]))) def test_check_failure_1_singular(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check([self.test_failure_1[0]], [self.test_failure_1[1]], MockUnit(None, self.test_failure_1[2]))) def test_check_failure_1_plural(self): if self.test_failure_1 is None: return self.assertTrue( self.check.check([self.test_failure_1[0]] * 2, [self.test_failure_1[1]] * 3, MockUnit(None, self.test_failure_1[2]))) def test_check_ignore_check(self): self.assertFalse( self.check.check([self.test_ignore_check[0]] * 2, [self.test_ignore_check[1]] * 3, MockUnit(None, self.test_ignore_check[2])))