Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

catch exception python unittest


import unittest
  
class MyTestCase(unittest.TestCase):
  
   # Returns true if 1 + '1' raises a TypeError
   def test_1(self):
      with self.assertRaises(Exception):
         1 + '1'
  
if __name__ == '__main__': 
    unittest.main()
Comment

PREVIOUS NEXT
Code Example
Python :: spacy get number of tokens 
Python :: relative text size put text cv2 
Python :: exit a pygame program 
Python :: Sum of Product 1 
Python :: plynomial regression implementation python 
Python :: python get type of variable 
Python :: beautifulsoup remove empty tags 
Python :: np.array([(1,2),(3,4)],dtype 
Python :: django form field add attrs 
Python :: Iterating Through Dictionaries with For Loops 
Python :: pytorch multiply tensors element by elementwise 
Python :: python windows os.listdir path usage 
Python :: max value pandas 
Python :: delete item from list python 
Python :: flask abort 
Python :: how to replace string in python 
Python :: run python script inside bash script 
Python :: concatenating strings in python 
Python :: remove dups in list of tuples 
Python :: dict_keys to list 
Python :: filter dataframe with a list of index 
Python :: replace in lists python 
Python :: ipython and virtualenvs 
Python :: pytorch convert tensor dtype 
Python :: django debug toolbar urlpatterns 
Python :: w=how to tell if decimal in python 
Python :: pandas df.index.values 
Python :: 1*2*3*4*5*6* - print on console?by python 
Python :: rename colonne pandas 
Python :: how to do merge sort in python 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =