Beispiel #1
0
 def test_unexpected_exception_type(self):
     def func(): raise IndexError()
     try:
         tt.assert_raises(ValueError, func)
     except AssertionError, e:
         expected = "func\(\) raised an unexpected exception type: expected=ValueError, actual=.*exceptions.IndexError.*"
         tt.assert_matches(expected, str(e))
Beispiel #2
0
 def test_expected_args_failure_error_message(self):
     def func(): raise RuntimeError(123, 456)
     try:
         tt.assert_raises(RuntimeError, func, expected_args=("abc", "def"))
     except AssertionError, e:
         expected = "func\(\) raised .*exceptions.RuntimeError.* with unexpected args: expected=\('abc', 'def'\), actual=\(123, 456\)"
         tt.assert_matches( expected, str(e) )
Beispiel #3
0
 def test_expected_regex_failure_error_message(self):
     def func(a, b): raise RuntimeError("%s - %s" %(a, b))
     try:
         tt.assert_raises(RuntimeError, func, 1, b=2, expected_regex="xxx")
     except AssertionError, e:
         import re
         expected = "func\(1, b=2\) raised .*exceptions.RuntimeError.*, but the regular expression 'xxx' doesn't match '1 - 2'"
         tt.assert_matches(expected, str(e))
Beispiel #4
0
def _verify_command_line_failure(output="", error="", rc=0, **kwargs):
    args = _generate_command(output=output, error=error, rc=rc)
    tt.assert_raises(
        AssertionError,
        tt.command_line,
        args,
        **kwargs
    )
Beispiel #5
0
    def test_expected_args_failure_error_message(self):
        def func():
            raise RuntimeError(123, 456)

        try:
            tt.assert_raises(RuntimeError, func, expected_args=("abc", "def"))
        except AssertionError, e:
            expected = "func\(\) raised .*exceptions.RuntimeError.* with unexpected args: expected=\('abc', 'def'\), actual=\(123, 456\)"
            tt.assert_matches(expected, str(e))
Beispiel #6
0
    def test_unexpected_exception_type(self):
        def func():
            raise IndexError()

        try:
            tt.assert_raises(ValueError, func)
        except AssertionError, e:
            expected = (
                "func\(\) raised an unexpected exception type: expected=ValueError, actual=.*exceptions.IndexError.*"
            )
            tt.assert_matches(expected, str(e))
Beispiel #7
0
    def test_expected_regex_failure_error_message(self):
        def func(a, b):
            raise RuntimeError("%s - %s" % (a, b))

        try:
            tt.assert_raises(RuntimeError, func, 1, b=2, expected_regex="xxx")
        except AssertionError, e:
            import re

            expected = "func\(1, b=2\) raised .*exceptions.RuntimeError.*, but the regular expression 'xxx' doesn't match '1 - 2'"
            tt.assert_matches(expected, str(e))
Beispiel #8
0
 def test_expected_regex_success(self):
     def func(): raise RuntimeError("shoo-bee-doo-bah")
     tt.assert_raises(
         RuntimeError, func, expected_regex="sh.*-.ee-[do]+-.*h$")
Beispiel #9
0
    def test_expected_exception(self):
        def func():
            raise ValueError()

        tt.assert_raises(ValueError, func)
Beispiel #10
0
 def test_expected_args_success(self):
     def func(): raise RuntimeError(123, 456)
     tt.assert_raises(RuntimeError, func, expected_args=(123,456))
Beispiel #11
0
 def test_kwargs_expected_exception(self):
     def func(**kwargs):
         if kwargs["x"] < 10: raise EnvironmentError()
     tt.assert_raises(EnvironmentError, func, x=5)
Beispiel #12
0
 def test_args_expected_exception(self):
     def func(x):
         if x < 10: raise TypeError()
     tt.assert_raises(TypeError, func, 5)
Beispiel #13
0
 def test_start_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.start)
Beispiel #14
0
 def test_dispatch_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.dispatch, lambda: "foo")
Beispiel #15
0
    def test_args_expected_exception(self):
        def func(x):
            if x < 10:
                raise TypeError()

        tt.assert_raises(TypeError, func, 5)
Beispiel #16
0
    def test_expected_regex_success(self):
        def func():
            raise RuntimeError("shoo-bee-doo-bah")

        tt.assert_raises(RuntimeError, func, expected_regex="sh.*-.ee-[do]+-.*h$")
Beispiel #17
0
    def test_expected_args_success(self):
        def func():
            raise RuntimeError(123, 456)

        tt.assert_raises(RuntimeError, func, expected_args=(123, 456))
Beispiel #18
0
    def test_kwargs_expected_exception(self):
        def func(**kwargs):
            if kwargs["x"] < 10:
                raise EnvironmentError()

        tt.assert_raises(EnvironmentError, func, x=5)
Beispiel #19
0
def _verify_command_line_failure(output="", error="", rc=0, **kwargs):
    args = _generate_command(output=output, error=error, rc=rc)
    tt.assert_raises(AssertionError, tt.command_line, args, **kwargs)
Beispiel #20
0
 def test_expected_exception(self):
     def func(): raise ValueError()
     tt.assert_raises(ValueError, func)
Beispiel #21
0
 def test_start_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.start)
Beispiel #22
0
 def test_dispatch_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.dispatch, lambda: "foo")