def test_make_friend_string(): try: myFriends = Friends() myFriends.make_friend(sys.argv[1]) except AttributeError: return "Test Passed" except: return "Test Failed EXPECTED: AttributeError, BUT WAS " + sys.exc_infor( )[0]
def test_make_friend_none(): try: myFriends = Friends() myFriends.make_none(None) except AttributeError: return "Test Passed" except: return "Test Failed EXPECTED: AttributeError, BUT WAS " + sys.exc_infor( )[0]
def test_make_friend_bool(myInput): myFriends = Friends() try: myFriends.make_friend(myInput) except AttributeError: return "Test Passed!" except: return "Test Failed EXPECTED: TypeError, BUT WAS " + sys.exc_infor()[0]
def test_make_friend_stringEm(): os.chdir('../reports') try: myFriends = Friends() myFriends.make_friend(sys.argv[1]) except AttributeError: print("Test Passed!") except: print("TEST FAILED, EXPECTED AttributeError, BUT WAS " + sys.exc_infor()[0])
def delete_payment(request): id = request.POST.get('id', '') if (id == ''): return HttpResponseRedirect('/payment/#mainsection') else: id = id.replace('popup', '') try: models.delete_process(id) except: print("Unexpected error: " + sys.exc_infor()[0]) return HttpResponseRedirect('/payment/#mainsection')
def build_graph_from(self, fn): try: # read lines in .txt file given to build graph with open(fn) as f: for line in f: try: node1, node2 = line.strip().split() # get node number from file (string type) n1, n2 = int(node1), int(node2) # transfer to int type self.Graph.add_nodes_from([n1, n2]) self.Graph.add_edge(n1, n2) if max(n1, n2) > self.max_node: self.max_node = max(n1, n2) except ValueError: print "Could not convert data to an integer or number of data doesn't match" except: print "Unexcepted error:", sys.exc_infor()[0] except IOError as (errno, strerror): print "I/O error({0}): {1} - {2}".format(errno, fn, strerror)