def test_negative_numbers(self): squares = {-1: 1, -2: 4, -3: 9, -12: 144, -100: 10000} for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}.".format(num))
def test_positive_numbers(self): squares = {1: 1, 2: 4, 3: 9, 12: 144, 100: 10000} for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}.".format(num))
class SquarerTest(): @staticmethod result = Squarer.calc(num) if result != square: print("Squared {} and got {} but expected {}.".format(num, result, square))
def test_positive_numbers(): squares = {1: 1, 2: 4, 3: 9, 12: 144, 100: 10000} for num, square in squares.items(): result = Squarer.calc(num) if result != square: print('Squared {} and got {} but was expecting {}'.format( num, result, square))
def test_negative_numbers(): squares = {-1: 1, -2: 4, -3: 9, -12: 144, -100: 10000} for num, square in squares.items(): result = Squarer.calc(num) if result != square: print("Squared {} and got {} but expected {}.".format(num, result, square))
def test_positive_numbers(): squares = { 1: 1, 2: 4, 3: 9, 12: 144, 100: 10000, } for num, square in squares.items(): result = Squarer.calc(num) if result != square: print("Squared {}, act {} exp {}".format(num, result, square))
def test_negative_numbers(): squares = { -1: 1, -2: 4, -3: 9, -12: 144, -100: 10000, } for num, square in squares.items(): result = Squarer.calc(num) if result != square: print("Squared {}, act {} exp {}".format(num, result, square))
def test_positive_numbers(self): """ Method: Test with + numbers. """ squares = { 1: 1, 2: 4, 3: 9, 12: 144, 100: 10000, } for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}".format(num))
def test_negative_numbers(self): """ Method: Test with - numbers. """ squares = { -1: 1, -2: 4, -3: 9, -12: 144, -100: 10000, } for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}".format(num))
def test_positive_numbers(): """ Method: Test with + numbers. """ squares = { 1: 1, 2: 4, 3: 9, 12: 144, 100: 10000, } for num, square in squares.items(): result = Squarer.calc(num) if result != square: print("Squared {} and got {} but expected {}".format( num, result, square))
def test_positive_numbers(): """The goal of this script is to define the expected behavior of Squarer and test quarer against that expected behavior. So we begin by creating a dictionary that defines that behavior:""" squares = { 1: 1, 2: 4, 3: 9, 12: 144, 100: 10000, } for num, square in squares.items(): result = Squarer.calc(num) if result != square: print("Squared {} and got {} but expected {}".format( num, result, square))
def test_pos_nums(self): squares = {1: 1, 2: 4, 3: 9, 100: 10000} for num, square in squares.items(): self.assertEqual(Squarer.calc(num), square, "Squaring {}".format(num))
def test_neg_nums(self): neg_squares = {-1: 1, -2: 4, -3: 9, -100: 10000} for num, square in neg_squares.items(): self.assertEqual(Squarer.calc(num), square, "Negative: squaring {}".format(num))
from squarer import Squarer class SquarerTest(unittest.TestCase): def test_positive_numbers(self): squares # { 1: 1, 2: 4, 3: 9, 12: 144, 100: 10000, } for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}".format(num)); def test_negative_numbers(self): squares # { -1: 1, -2: 4, -3: 9, -12: 144, -100: 10000, } for num, square in squares.items(): self.assertEqual(square, Squarer.calc(num), "Squaring {}".format(num));