def test_rectangle_area_again(): """ Test that we can calculate the area of a rectangle """ rectangle = Rectangle(width=8, height=8) area = rectangle.area() assert area == 64
class RectangleTestCase(TestCase): def setUp(self): self.rectangle = Rectangle(width=7, height=8) def test_rectangle_area(self): """ Test that we can calculate the area of a rectangle """ area = self.rectangle.area() self.assertEqual(area, 56) @mock.patch('shapes.tweet') def test_rectangle_broadcast(self, mock_tweet): """ Tests that we call tweet with a formatted message """ self.rectangle.broadcast() mock_tweet.assert_called_with('My rectangle is 7 by 8')
This program tests the functionality of 'shapes' and 'complex'. """ from complex import Complex from shapes import Rectangle, Circle import random # Test attributes of the circle class c = Circle(1.2) a = c.area() p = c.perimeter() d = c.diameter() # Test attributes of rectangle class r = Rectangle(3, 4) a2 = r.area() p2 = r.perimeter() print(a, ' ', p, ' ', d, ' ', a2, ' ', p2) # Test attributes of complex class # count = 0 # complex_array = [] # for i in range (100): # real = 10 * random.random() # imag = -15 * random.random() # check_py = (complex(real, imag)) # check_me = (Complex(real, imag)) # complex_array[i][0].append(real) # complex_array[i][1].append(imag) # if check_py != check_me:
#!/usr/bin/env python #Author: Makenzie Brian #Date: February 14, 2018 #Class: ME 599 #File: lab5 > testfile.py #Description: test for classes from complex import Complex from shapes import Circle from shapes import Rectangle if __name__ == '__main__': a = Complex(1.0, '-2.3') b = Complex(2) c = Complex() d = Complex(1, -1) print a, b, c, d, '\n' c = Circle('21') a = c.area() d = c.diameter() p = c.perimeter() r = Rectangle('3', 4) ar = r.area() pr = r.perimeter() print a, d, p print ar, pr