Advertisement
colinm86

Untitled

Oct 7th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.69 KB | None | 0 0
  1. from ch_two_exercises import *
  2. import unittest
  3. class TestStringMethods(unittest.TestCase):
  4.     """Unit tests for Fractions Class
  5.    Arguments:
  6.        unittest {unittest}
  7.    """
  8.     def test_list_index_time(self):
  9.         self.assertIsInstance(list_index_time(10000,100001,10000), dict)
  10.         self.assertEqual(len(list_index_time(10000,100001,10000)),10)
  11.  
  12.     def test_get_indx_time(self):
  13.         lst = [1,2,3,4,5,6,7,8,9,10]
  14.         indx = 2
  15.         self.assertIsInstance(get_indx_time(lst,indx), float)
  16.         with self.assertRaises(IndexError):
  17.             get_indx_time(lst,100)
  18.  
  19.     def test_dictionary_get_time(self):
  20.         self.assertIsInstance(dictionary_get_time(10000,100001,10000), dict)
  21.         self.assertEqual(len(dictionary_get_time(10000,100001,10000)),10)
  22.         self.assertEqual(len(dictionary_get_time(1000,100001,1000)),100)  
  23.  
  24.     def test_dictionary_set_time(self):
  25.         self.assertIsInstance(dictionary_set_time(10000,100001,10000), dict)
  26.         self.assertEqual(len(dictionary_set_time(10000,100001,10000)),10)
  27.         self.assertEqual(len(dictionary_set_time(1000,100001,1000)),100)
  28.  
  29.     def test_get_set_dict_time(self):
  30.         self.assertIsInstance(get_set_dict_time({"1": None,"2":None,"3":None},2), float)
  31.         self.assertIsInstance(get_set_dict_time({"1": None,"2":None,"3":None},100), float)
  32.    
  33.     def test_dictionary_get_time(self):
  34.         x,y = lst_vs_dictionary_del_time(10000,100001,10000)
  35.         self.assertIsInstance(x, list)
  36.         self.assertIsInstance(y, dict)
  37.         self.assertEqual(len(x),10)
  38.         self.assertEqual(len(y),10)
  39.  
  40.     def test_del_lst_time(self):
  41.         lst = [x for x in range(1000)]
  42.         lst2 = [x for x in range(10)]
  43.         self.assertIsInstance(del_lst_time(lst), float)
  44.         self.assertIsInstance(del_lst_time(lst2), float)
  45.  
  46.     def test_del_dict_time(self):
  47.         dct = {x:'test' for x in range(1000)}
  48.         dct2 = {x:'test' for x in range(10)}
  49.         self.assertIsInstance(del_dict_time(dct), float)
  50.         self.assertIsInstance(del_dict_time(dct2), float)
  51.  
  52.     def test_find_k_smallest_n_log_n(self):
  53.         k = 2
  54.         k2 = 3
  55.         lst = [0,20,8,15]
  56.         self.assertEqual(find_k_smallest_n_log_n(k,lst),8)
  57.         self.assertEqual(find_k_smallest_n_log_n(k2,lst),15)
  58.         with self.assertRaises(TypeError):
  59.             find_k_smallest_n_log_n(True,100)
  60.         with self.assertRaises(Exception):
  61.             find_k_smallest_n_log_n(2,[])
  62.         with self.assertRaises(Exception):
  63.             find_k_smallest_n_log_n(5,[0,20,10,3])
  64.  
  65.    
  66.     def test_gen_rndm_num_arr(self):
  67.         self.assertEqual(len(gen_rndm_num_arr(10)),10)
  68.         self.assertEqual(len(gen_rndm_num_arr(100)),100)
  69.  
  70.  
  71.  
  72. if __name__ == '__main__':
  73.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement