コード例 #1
0
class NetTests(unittest.TestCase):
    """ The tests of the core module net feature """

    def setUp(self):
        """ Setup the test case. """
        self.net = Net("001")

    def tearDown(self):
        """ Teardown the test case. """
        pass

    def test_create_new_net(self):
        """ Test the creation of a new empty net. """
        assert self.net.net_id == "001"

    def test_bounds_simple(self):
        """Make sure bounds() uses all the included NetPoints"""
        for (x, y) in ((1, 3), (3, 2), (4, 3), (3, 5)):
            net_pt = NetPoint(str((x, y)), x, y)
            self.net.add_point(net_pt)
            # NetPoints don't actually need to be connected to affect bounds()

        top_left, btm_right = self.net.bounds()
        self.assertEqual(top_left.x, 1)
        self.assertEqual(top_left.y, 2)
        self.assertEqual(btm_right.x, 4)
        self.assertEqual(btm_right.y, 5)