Question
Assignment 3 : Python Benchmarking, Logging, and Unit Testing Purpose : Practice using Python benchmarking, logging, and unit testing . Grades will start at 100%
Assignment 3: Python Benchmarking, Logging, and Unit Testing
Purpose: Practice using Python benchmarking, logging, and unit testing.
Grades will start at 100% and then deductions made for errors preventing the correct answer to be calculated, or if the solution does not use Python classes, inheritance and overloading.
Individual Assignment: Hand-In your own Python source code (submit to Assignment object in Moodle). Feel free to collaborate in your groups, but dont copy the groups solution. Copied solutions (both originator and user) will receive a grade of 0.
Due in 2 weeks (allows us to resolve any doubts during the following class).
Name your zip file: [your name]+[your ID]+assignment 3.zip
Use only standard Python libraries (i.e. timeit, logging, unittest, etc. and native Python code) to solve.
Assignment code files will be file-compared with the class. Identical or nearly identical submissions will both receive 0.
Problem:
Revisit your Assignment 2 (if you need Assignment 2 code let me know) and:
Example Code Snippet (doesnt run, has defects but outlines an approach, provided as a starting point, feel free to modify, improve and create your approach)
from unittest import TestCase
import DirectedEdge
class TestDirectedEdge(TestCase):
def setUp(self):
self.directed_edge0 = DirectedEdge.DirectedEdge('A', 1)
got_expected_assertion = False
try:
self.directed_edge1 = DirectedEdge.DirectedEdge('B', 0)
except AssertionError as e:
got_expected_assertion = True
if not got_expected_assertion:
self.fail()
.
def test_get_to_vertex(self):
self.assertGreater(len(self.directed_edge0.get_to_vertex()), 0)
self.assertGreater(len(self.directed_edge3.get_to_vertex()), 0)
.
class TestProblem(TestCase):
def setUp(self):
directed_graph = DirectedGraph.DirectedGraph()
got_expected_assertion = False
try:
Problem.Problem(-1, directed_graph)
except AssertionError as e:
got_expected_assertion = True
if not got_expected_assertion:
self.fail()
got_expected_assertion = False
try:
Problem.Problem(1, directed_graph)
except AssertionError as e:
got_expected_assertion = True
if not got_expected_assertion:
self.fail()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started