예제 #1
0
파일: nose.py 프로젝트: EasyPost/doubles
        def wrapped(result):
            test.test(result)

            try:
                verify()
            except MockExpectationError:
                result.addFailure(test.test,  sys.exc_info())
예제 #2
0
 def verify_and_teardown_doubles():
     try:
         verify()
     except Exception as e:
         pytest.fail(str(e))
     finally:
         teardown()
예제 #3
0
파일: nose.py 프로젝트: uber/doubles
        def wrapped(result):
            test.test(result)

            try:
                verify()
            except MockExpectationError:
                result.addFailure(test.test,  sys.exc_info())
예제 #4
0
        def test_unsatisfied_expectation(self, test_class):
            TestClass = ClassDouble(test_class)

            expect_constructor(TestClass)
            with raises(MockExpectationError):
                verify()
            teardown()
예제 #5
0
        def test_unsatisfied_expectation(self, test_class):
            TestClass = ClassDouble(test_class)

            expect_constructor(TestClass)
            with raises(MockExpectationError):
                verify()
            teardown()
예제 #6
0
 def verify_and_teardown_doubles():
     try:
         verify()
     except Exception as e:
         pytest.fail(str(e))
     finally:
         teardown()
예제 #7
0
def pytest_runtest_call(item):
    outcome = yield

    try:
        outcome.get_result()
        verify()
    finally:
        teardown()
예제 #8
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_takes_precedence_over_subsequent_allowances(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).instance_method
        allow(subject).instance_method.and_return('foo')

        with raises(MockExpectationError):
            verify()

        teardown()
예제 #9
0
    def test_takes_precedence_over_subsequent_allowances(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).instance_method
        allow(subject).instance_method.and_return('foo')

        with raises(MockExpectationError):
            verify()

        teardown()
예제 #10
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_unsatisfied_expectation(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).__exit__.once()

        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected '__exit__' to be called 1 time instead of 0 times on "
            r"<InstanceDouble of <class 'doubles.testing.User'> object at .+> "
            r"with any args, but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)", str(e.value))
예제 #11
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_fails_when_called_less_than_at_least_times(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).instance_method.at_least(2).times

        subject.instance_method()
        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'instance_method' to be called at least 2 times instead of 1 time on "
            r"<InstanceDouble of <class 'doubles.testing.User'> object at .+> "
            r"with any args, but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)", str(e.value))
예제 #12
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_raises_if_an_expected_method_call_with_args_is_not_made(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).method_with_varargs.with_args('bar')

        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'method_with_varargs' to be called on "
            r"<InstanceDouble of <class '?doubles.testing.User'?"
            r"(?: at 0x[0-9a-f]{9})?> object at .+> "
            r"with \('bar'\), but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)", str(e.value))
예제 #13
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_unsatisfied_expectation(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).__exit__.once()

        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected '__exit__' to be called 1 time instead of 0 times on "
            r"<InstanceDouble of <class 'doubles.testing.User'> object at .+> "
            r"with any args, but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)",
            str(e.value)
        )
예제 #14
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_raises_if_an_expected_method_call_with_default_args_is_not_made(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).method_with_default_args.with_args('bar', bar='barker')

        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'method_with_default_args' to be called on "
            r"<InstanceDouble of <class '?doubles.testing.User'?"
            r"(?: at 0x[0-9a-f]{9})?> object at .+> "
            r"with \('bar', bar='barker'\), but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)",
            str(e.value)
        )
예제 #15
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_fails_when_called_less_than_at_least_times(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).instance_method.at_least(2).times

        subject.instance_method()
        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'instance_method' to be called at least 2 times instead of 1 time on "
            r"<InstanceDouble of <class 'doubles.testing.User'> object at .+> "
            r"with any args, but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)",
            str(e.value)
        )
예제 #16
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_with_args_validator_not_called(self):
        subject = InstanceDouble('doubles.testing.User')

        def arg_matcher(*args):
            return True

        expect(subject).method_with_varargs.with_args_validator(arg_matcher)
        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'method_with_varargs' to be called on "
            r"<InstanceDouble of <class '?doubles.testing.User'?"
            r"(?: at 0x[0-9a-f]{9})?> object at .+> "
            r"with custom matcher: 'arg_matcher', but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)", str(e.value))
예제 #17
0
파일: expect_test.py 프로젝트: uber/doubles
    def test_with_args_validator_not_called(self):
        subject = InstanceDouble('doubles.testing.User')

        def arg_matcher(*args):
            return True
        expect(subject).method_with_varargs.with_args_validator(arg_matcher)
        with raises(MockExpectationError) as e:
            verify()
        teardown()

        assert re.match(
            r"Expected 'method_with_varargs' to be called on "
            r"<InstanceDouble of <class '?doubles.testing.User'?"
            r"(?: at 0x[0-9a-f]{9})?> object at .+> "
            r"with custom matcher: 'arg_matcher', but was not."
            r" \(.*doubles/test/expect_test.py:\d+\)",
            str(e.value)
        )
예제 #18
0
 def verify_and_teardown_doubles():
     try:
         verify()
     finally:
         teardown()
예제 #19
0
파일: pytest.py 프로젝트: sladebot/doubles
def pytest_runtest_call(item, __multicall__):
    try:
        __multicall__.execute()
        verify()
    finally:
        teardown()
예제 #20
0
파일: unittest.py 프로젝트: uber/doubles
 def wrapper():
     test_func()
     verify()
예제 #21
0
파일: unittest.py 프로젝트: uber/doubles
 def wrapper():
     test_func()
     verify()