test_linked_lists copy.py - import random import io import...

This preview shows page 1 - 2 out of 3 pages.

import randomimport ioimport sysimport pytestimport mathfrom course import Coursefrom courselist import CourseListdef test_course_creation():# make sure that an empty course is correctc = Course()assert c.name() == ""assert c.number() == 0assert c.credit_hr() == 0.0assert c.grade() == 0.0assert c.next == Nonedef test_course_creation_with_parameters():c = Course(1234, "Test Name", 3.0, 3.72)assert c.number() == 1234assert c.name() == "Test Name"assert c.credit_hr() == 3.0assert c.grade() == 3.72assert c.next == Nonewith 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)def test_empty_courselist():cl = CourseList()assert cl.head == Noneassert cl.size() == 0assert cl.calculate_gpa() == 0.0assert cl.calculate_gpa() == 0.0assert cl.is_sorted()def test_insert():random.seed(0)cl = CourseList()for _ in range(37):

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 3 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
CharlesD.Allison
Tags
course import Course, pylint import epylint

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture