import unittest
import sys
import os
import math

import Shape

class TestPythonBindings(unittest.TestCase):
  def setUp(self):
    self.radius = 3.0
    self.circle = Shape.Circle(self.radius)

  def tearDown(self):
    del self.circle
  
  def test_Shape_Circle_is_called_Circle(self):
    self.assertEqual("Circle", self.circle.name())

  def test_Shape_Circle_has_expected_area(self):
    area = self.radius * self.radius * math.pi
    
    self.assertAlmostEqual(area, self.circle.area())

  def test_Shape_Circle_has_expected_perimeter(self):
    perimeter = 2.0 * math.pi * self.radius
    
    self.assertAlmostEqual(perimeter, self.circle.perimeter())

  def test_Shape_Circle_is_equal_to_self(self):
    self.assertTrue(self.circle.is_equal(self.circle))

  def test_Shape_Circle_is_equal_to_circle_with_same_radius(self):
    self.assertTrue(self.circle.is_equal(Shape.Circle(self.radius)))
  
  def test_Shape_Circle_is_not_equal_to_circle_with_different_radius(self):
    self.assertFalse (self.circle.is_equal(Shape.Circle(self.radius+1)))
  
  def test_Shape_Circle_is_not_equal_to_square(self):
    self.assertFalse(self.circle.is_equal(Shape.Square(4)))

  def test_exception_on_negative_radius(self):
    with self.assertRaisesRegexp(Shape.Shape_error, 'Circle radius "-1.000000" must be non-negative.'):
      Shape.Circle(-1)

def main():
  unittest.main()

if __name__ == '__main__':
  main()


@@ -1,20 +1,4 @@
-import unittest%0A
 impo
@@ -30,201 +30,34 @@
 ath%0A
-%0A
 import 
-Shape%0A%0Aclass TestPythonBindings(unittest.TestCase):%0A  def setUp(self):%0A    self.radius = 3.0%0A    self.circle = Shape.Circle(self.radius)%0A%0A  def tearDown(self):%0A    del self.circle%0A  %0A  
+nose%0Aimport Shape%0A%0A
 def 
@@ -95,69 +95,69 @@
 cle(
-self
 ):%0A    
-self.assertEqual(%22Circle%22, self.circle.name())%0A%0A  
+c = Shape.Circle(3)%0A    assert c.name() == %22Circle%22%0A%0A%0A
 def 
@@ -196,123 +196,152 @@
 rea(
-self
 ):%0A    
-area = self.radius * self.radius * math.pi%0A    %0A    self
+r = 2.0%0A    c = Shape.Circle(r)%0A    a = math.pi * r * r%0A    print a%0A    print c.area()%0A    nose.tools
 .assert
-A
+_a
 lmost
-E
+_e
 qual(
-area, self.circle
+c
 .area()
+, a
 )%0A%0A
-  
+%0A
 def 
@@ -385,113 +385,109 @@
 ter(
-self
 ):%0A    
-perimeter = 2.0 * math.pi * self.radius%0A    %0A    self
+r = 2.0%0A    c = Shape.Circle(r)%0A    p = 2.0 * math.pi * r%0A    nose.tools
 .assert
-A
+_a
 lmost
-E
+_e
 qual(
-perimeter, self.circle
+c
 .per
@@ -494,21 +494,23 @@
 imeter()
+, p
 )%0A%0A
-  
+%0A
 def test
@@ -539,78 +539,69 @@
 _to_
+it
 self(
-self
 ):%0A    
-self.assertTrue(self.circle.is_equal(self.circle))%0A%0A  
+c = Shape.Circle(2)%0A    assert c.is_equal(c)%0A%0A%0A
 def 
@@ -622,32 +622,40 @@
 cle_is_equal_to_
+another_
 circle_with_same
@@ -650,16 +650,20 @@
 le_with_
+the_
 same_rad
@@ -670,89 +670,90 @@
 ius(
-self
 ):%0A    
-self.assertTrue(self.circle.is_equal(Shape.Circle(self.radius)))%0A  %0A  
+c1 = Shape.Circle(2)%0A    c2 = Shape.Circle(2)%0A    assert c1.is_equal(c2)%0A%0A%0A
 def 
@@ -819,93 +819,93 @@
 ius(
-self
 ):%0A    
-self.assertFalse (self.circle.is_equal(Shape.Circle(self.radius+1)))%0A  %0A  
+c1 = Shape.Circle(2)%0A    c2 = Shape.Circle(3)%0A    assert not c1.is_equal(c2)%0A%0A
 def 
@@ -949,222 +949,150 @@
 are(
-self
 ):%0A    
-self.assertFalse(self.circle.is_equal(Shape.Square(4)))%0A%0A  def test_exception_on_negative_radius(self):%0A    with self.assertRaisesRegexp(Shape.Shape_error, 'Circle radius %22-1.000000%22 must be non-
+c = Shape.Circle(2)%0A    s = Shape.Square(2)%0A    assert not c.is_equal(s)%0A%0A%0A@nose.tools.raises(Exception)%0Adef test_exception_on_
 negative
 .'):
@@ -1091,15 +1091,19 @@
 tive
-.'
+_radius(
 ):%0A
-  
     
@@ -1124,72 +1124,4 @@
 1)%0A%0A
-def main():%0A  unittest.main()%0A%0Aif __name__ == '__main__':%0A  main()%0A%0A

use nose for shape tests