CSC148H1 Lecture Notes - List Of Unit Testing Frameworks, Exception Handling, 1.-Class Torpedo Boat

69 views3 pages
11 Jan 2013
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

Exceptions: try and except conditions: if the code under try statements works, skips the except condition, if error occurs, python compares error raised to exception typed specified by the except. A match = execute except block: ex, try, x = 1/0, except exception as error: # except exception catches all exceptions, print error # error message raised in the try block. Throw very specific exception in lower levels of program, catch only at higher level. Raise exceptions: if x == 0, raise exception( x is zero", more specific exception, def divide(top, bottom), if bottom == 0, raise valueerror( divisor is zero", else, return top / bottom. Only one error rasied at a time: ex, assert 3 == 4, assert 1 == 5, one failure, assert error in the first line. Raise called exits current program and gives error. Options: nose (separate install, but doesn"t use classes, pyunit/unittest (comes with python!, doctest (comes with python!)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents