Ejemplo n.º 1
0
def test_course_creation():
    # make sure that an empty course is correct
    c = Course()
    assert c.name() == ""
    c.number() == 0
    assert c.credit_hr() == 0.0
    assert c.grade() == 0.0
Ejemplo n.º 2
0
 def test_course_creation(self):
     # make sure that an empty course is correct
     c = Course()
     self.assertEqual(c.name(), "")
     self.assertEqual(c.number(), 0)
     self.assertEqual(c.credit_hr(), 0.0)
     self.assertEqual(c.grade(), 0.0)
     self.assertEqual(c.next, None)
Ejemplo n.º 3
0
    def test_course_creation_with_parameters(self):
        c = Course(1234, "Test Name", 3.0, 3.72)
        self.assertEqual(c.number(), 1234)
        self.assertEqual(c.name(), "Test Name")
        self.assertAlmostEqual(c.credit_hr(), 3.0)
        self.assertAlmostEqual(c.grade(), 3.72)
        self.assertIsNone(c.next)

        self.assertRaises(ValueError, Course, "cat")
        self.assertRaises(ValueError, Course, 1234, None)
        self.assertRaises(ValueError, Course, 1234, "Test Name", "cat")
        self.assertRaises(ValueError, Course, 1234, "Test Name", 3.0, "cat")
        self.assertRaises(ValueError, Course, -1)
        self.assertRaises(ValueError, Course, 1234, "Test Name", -2.1)
        self.assertRaises(ValueError, Course, 1234, "Test Name", 0.0, -2.0)
Ejemplo n.º 4
0
def test_course_creation_with_parameters():
    c = Course(1234, "Test Name", 3.0, 3.72)
    assert c.number() == 1234
    assert c.name() == "Test Name"
    assert c.credit_hr() == 3.0
    assert c.grade() == 3.72

    with pytest.raises(ValueError):
        Course("cat")
    with pytest.raises(ValueError):
        Course(1234, None)
    with pytest.raises(ValueError):
        Course(1234, "Test Name", "cat")
    with pytest.raises(ValueError):
        Course(1234, "Test Name", 3.0, "cat")
    with pytest.raises(ValueError):
        Course(-1)
    with pytest.raises(ValueError):
        Course(1234, "Test Name", -2.1)
    with pytest.raises(ValueError):
        Course(1234, "Test Name", 0.0, -2.0)