示例#1
0
 def it_should_do_true_assets(self):
     expect(True).to_be(True)
     expect([1]).to_be(True)
     with expect.to_raise(AssertionError):
         expect(False).to_be(True)
     with expect.to_raise(AssertionError):
         expect([]).to_be(True)
示例#2
0
 def it_should_do_not_false_asserts(self):
     expect(True).not_to_be(False)
     expect([1]).not_to_be(False)
     with expect.to_raise(AssertionError):
         expect(False).not_to_be(False)
     with expect.to_raise(AssertionError):
         expect([]).not_to_be(False)
示例#3
0
    def it_should_do_not_instance_of_asserts(self):
        class Test:
            pass
        obj = Test()
        expect(1).not_to_be_instance_of(str)
        expect(obj).not_to_be_instance_of(int)

        with expect.to_raise(AssertionError):
            expect(1).not_to_be_instance_of(int)
        with expect.to_raise(AssertionError):
            expect(obj).not_to_be_instance_of(Test)
示例#4
0
 def it_should_raise_exception_if_different_exception_raised(self):
     cought = False
     try:
         with expect.to_raise(self.CustomException):
             raise AssertionError()
     except AssertionError:
         cought = True
     expect(cought).to_be(True)
示例#5
0
 def it_should_raise_exception_if_none_exceptions_raised(self):
     cought = False
     try:
         with expect.to_raise(AssertionError):
             pass
     except AssertionError:
         cought = True
     expect(cought).to_be(True)
示例#6
0
    def it_should_do_equality_asserts(self):
        expect(1) == 1
        expect(1) != 2
        expect(2) < 3
        expect(3) > 2
        expect(2) <= 2
        expect(3) >= 2

        with expect.to_raise(AssertionError):
            expect(1) == 2
        with expect.to_raise(AssertionError):
            expect(2) != 2
        with expect.to_raise(AssertionError):
            expect(3) < 2
        with expect.to_raise(AssertionError):
            expect(2) > 3
        with expect.to_raise(AssertionError):
            expect(3) <= 2
        with expect.to_raise(AssertionError):
            expect(2) >= 3
示例#7
0
 def it_should_catch_expected_exceptions(self):
     with expect.to_raise(AssertionError):
         raise AssertionError()
     with expect.to_raise(self.CustomException):
         raise self.CustomException()
示例#8
0
 def it_should_do_is_asserts(self):
     a = object()
     b = object()
     expect(a).not_to_be(b)
     with expect.to_raise(AssertionError):
         expect(a).not_to_be(a)
示例#9
0
 def it_patch_with_attributes_specification(self):
     expect(flowp.testing.dummy.test_var) == 0
     self.mock(self.o, 'a', spec=['a'])
     self.o.a
     with expect.to_raise(AttributeError):
         self.o.a.c
示例#10
0
 def it_raise_an_error_if_target_is_not_a_string(self):
     o = object()
     with expect.to_raise(TypeError):
         self.mock(o)
示例#11
0
 def it_creates_mocks_with_attributes_specification(self):
     m = self.mock(spec=['a'])
     m.a
     with expect.to_raise(AttributeError):
         m.b
示例#12
0
 def it_should_do_called_n_times_assert(self):
     self.m()
     self.m()
     expect(self.m).to_have_been_called(2)
     with expect.to_raise(AssertionError):
         expect(self.m).to_have_been_called(1)
示例#13
0
 def it_should_do_called_with_assert(self):
     self.m(1, 2, 3)
     expect(self.m).to_have_been_called_with(1, 2, 3)
     with expect.to_raise(AssertionError):
         expect(self.m).to_have_been_called_with(0, 2, 3)
示例#14
0
 def it_should_do_not_called_assert(self):
     expect(self.m).not_to_have_been_called()
     self.m()
     with expect.to_raise(AssertionError):
         expect(self.m).not_to_have_been_called()
示例#15
0
 def it_should_do_called_assert(self):
     self.m()
     expect(self.m).to_have_been_called()
     self.m.reset_mock()
     with expect.to_raise(AssertionError):
         expect(self.m).to_have_been_called()
示例#16
0
 def it_should_do_not_in_asserts(self):
     expect(4).not_to_be_in([1, 2, 3])
     with expect.to_raise(AssertionError):
         expect(1).not_to_be_in([1, 2, 3])