def test_check_def_and_class_not_in_class_class(self): ex1 = 'line: 54, column: 0 too many blank lines ({0})' ex2 = 'line: 54, column: 0 too few empty lines ({0})' result1 = t.check_def_and_class("class Game:", 54, 3, False, False)[3] result2 = t.check_def_and_class("class Game:", 54, 1, False, False)[3] self.assertEqual(result1, ex1.format(3)) self.assertEqual(result2, ex2.format(1))
def test_check_def_and_class_in_class_def(self): ex1 = 'line: 57, column: 0 too many blank lines ({0})' ex2 = 'line: 57, column: 0 too few empty lines ({0})' result1 = t.check_def_and_class(" def get_square(a, b):", 57, 2, True, False)[3] result2 = t.check_def_and_class(" def get_square(a, b):", 57, 0, True, False)[3] self.assertEqual(result1, ex1.format(2)) self.assertEqual(result2, ex2.format(0))
def test_check_def_and_class_in_class_class(self): ex1 = 'line: 56, column: 0 too many blank lines ({0})' ex2 = 'line: 56, column: 0 too few empty lines ({0})' result1 = t.check_def_and_class(" class Game:", 56, 2, True, False)[3] result2 = t.check_def_and_class(" class Game:", 56, 0, True, False)[3] self.assertEqual(result1, ex1.format(2)) self.assertEqual(result2, ex2.format(0))
def test_check_def_and_class_not_in_class_def(self): ex1 = 'line: 55, column: 0 too many blank lines ({0})' ex2 = 'line: 55, column: 0 too few empty lines ({0})' result1 = t.check_def_and_class("def get_square(a, b):", 55, 3, False, False)[3] result2 = t.check_def_and_class("def get_square(a, b):", 55, 1, False, False)[3] self.assertEqual(result1, ex1.format(3)) self.assertEqual(result2, ex2.format(1))
def test_check_def_and_class_empty(self): ex = 'line: 59, column: 0 blank line contains whitespace' results = [] results.append( t.check_def_and_class("sum = a + b", 59, 1, False, False)[3]) results.append( t.check_def_and_class("sum = a + b", 59, 1, True, False)[3]) results.append( t.check_def_and_class("sum = a + b", 59, 1, True, True)[3]) for e in results: self.assertEqual(e, ex)
def test_check_def_and_class_in_class_previous_class(self): ex = 'line: 58, column: 0 blank line contains whitespace' result = t.check_def_and_class(" def get_square(a, b):", 58, 1, True, True)[3] self.assertEqual(result, ex)