Ejemplo n.º 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))
Ejemplo n.º 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) )
Ejemplo n.º 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))
Ejemplo n.º 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
    )
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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$")
Ejemplo n.º 9
0
    def test_expected_exception(self):
        def func():
            raise ValueError()

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

        tt.assert_raises(TypeError, func, 5)
Ejemplo n.º 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$")
Ejemplo n.º 17
0
    def test_expected_args_success(self):
        def func():
            raise RuntimeError(123, 456)

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

        tt.assert_raises(EnvironmentError, func, x=5)
Ejemplo n.º 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)
Ejemplo n.º 20
0
 def test_expected_exception(self):
     def func(): raise ValueError()
     tt.assert_raises(ValueError, func)
Ejemplo n.º 21
0
 def test_start_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.start)
Ejemplo n.º 22
0
 def test_dispatch_raises(self):
     tt.assert_raises(threadpool.Error, self.pool.dispatch, lambda: "foo")