예제 #1
0
 def test000_restore_but_reuse(self):
     base = SinonBase()
     base.restore()
     exception = "weakly-referenced object no longer exists"
     with self.assertRaises(Exception) as context:
         base.called
     self.assertTrue(exception in str(context.exception)) # test weakref errmsg
예제 #2
0
 def test016_constructor_library_module_method(self):
     base = SinonBase(os, "system")
     base.restore()
예제 #3
0
 def test015_constructor_custom_module_method(self):
     base = SinonBase(A_object, "A_func")
     base.restore()
예제 #4
0
 def test014_constructor_module_reassigned(self):
     base = SinonBase(os)
     with self.assertRaises(Exception) as context:
         base = SinonBase(os)
     base.restore()
예제 #5
0
 def test013_constructor_module_repeated(self):
     base1 = SinonBase(os)
     with self.assertRaises(Exception) as context:
         base2 = SinonBase(os)
     base1.restore()
예제 #6
0
 def test012_constructor_library_module(self):
     base = SinonBase(os)
     base.restore()
예제 #7
0
 def test022_constructor_module_variable(self):
     with self.assertRaises(Exception) as context:
         base = SinonBase(os, "path") 
예제 #8
0
 def test019_constructor_method(self):
     base = SinonBase(B_func)
     base.restore()
예제 #9
0
 def test029_constructor_invalid_method_type(self):
     A = A_object()
     with self.assertRaises(Exception) as context:
         base = SinonBase(A, 123)
예제 #10
0
 def test028_constructor_instance_wrong_method(self):
     A = A_object()
     with self.assertRaises(Exception) as context:
         base = SinonBase(A, "not_exist_function")
예제 #11
0
 def test027_constructor_instance(self):
     A = A_object()
     base = SinonBase(A)
     base.restore()
예제 #12
0
 def test026_constructor_outside_class_and_instance(self):
     fto = ForTestOnly()
     base1 = SinonBase(ForTestOnly)
     with self.assertRaises(Exception) as context:
         base2 = SinonBase(fto)
     base1.restore()
예제 #13
0
 def test025_constructor_outside_instance(self):
     fto = ForTestOnly()
     base = SinonBase(fto)
     base.restore()
예제 #14
0
 def test024_constructor_outside_class(self):
     base = SinonBase(ForTestOnly)
     base.restore()
예제 #15
0
 def test017_constructor_module_method_repeated(self):
     base = SinonBase(os, "system")
     with self.assertRaises(Exception) as context:
         base = SinonBase(os, "system")
     base.restore()
예제 #16
0
 def test018_constructor_empty(self):
     base = SinonBase()
     base.restore()
예제 #17
0
 def test011_constructor_custom_module(self):
     base = SinonBase(A_object)
     base.restore()
예제 #18
0
 def test020_constructor_method_repeated(self):
     base = SinonBase(B_func)
     with self.assertRaises(Exception) as context:
         base = SinonBase(B_func)
     base.restore()
예제 #19
0
 def test021_constructor_instance_method(self):
     A = A_object()
     base = SinonBase(A, "A_func")
     base.restore()