Example #1
0
 def test_fails_when_warnings_test_raises_exception_with_callable(self):
     """
     Test that assert_warns_such_that (when given a callable object)
     fails when the warnings_test method raises an exception.
     """
     with assertions.assert_raises(RuntimeError):
         assertions.assert_warns_such_that(self._raise_exception,
                                           self._create_user_warning)
Example #2
0
 def test_fails_when_warnings_test_raises_exception_with_callable(self):
     """
     Test that assert_warns_such_that (when given a callable object)
     fails when the warnings_test method raises an exception.
     """
     with assertions.assert_raises(RuntimeError):
         assertions.assert_warns_such_that(self._raise_exception,
                                           self._create_user_warning)
Example #3
0
    def test_passes_when_warnings_test_returns_true_with_callable(self):
        """
        Test that assert_warns_such_that (when given a callable object)
        passes when the warnings_test method returns True.
        This should happen if warnings is populated correctly.
        """
        def create_multiple_warnings(warnings_count):
            for _ in range(warnings_count):
                self._create_user_warning()

        three_warnings_caught = lambda warnings: assert_equal(len(warnings), 3)
        assertions.assert_warns_such_that(three_warnings_caught,
                                          create_multiple_warnings, 3)
Example #4
0
    def test_passes_when_warnings_test_returns_true_with_callable(self):
        """
        Test that assert_warns_such_that (when given a callable object)
        passes when the warnings_test method returns True.
        This should happen if warnings is populated correctly.
        """
        def create_multiple_warnings(warnings_count):
            for _ in range(warnings_count):
                self._create_user_warning()

        three_warnings_caught = lambda warnings: assert_equal(len(warnings), 3)
        assertions.assert_warns_such_that(three_warnings_caught,
                                          create_multiple_warnings, 3)
Example #5
0
 def test_fails_when_warnings_test_raises_exception(self):
     """
     Test that assert_warns_such_that (used as a context manager)
     fails when the warnings_test method raises an exception.
     """
     with assertions.assert_raises(RuntimeError):
         with assertions.assert_warns_such_that(self._raise_exception):
             self._create_user_warning()
Example #6
0
 def test_fails_when_warnings_test_raises_exception(self):
     """
     Test that assert_warns_such_that (used as a context manager)
     fails when the warnings_test method raises an exception.
     """
     with assertions.assert_raises(RuntimeError):
         with assertions.assert_warns_such_that(self._raise_exception):
             self._create_user_warning()
Example #7
0
    def test_passes_when_warnings_test_returns_true(self):
        """
        Test that assert_warns_such_that (used as a context manager)
        passes when the warnings_test method returns True.
        This should happen if warnings is populated correctly.
        """
        def one_user_warning_caught(warnings):
            assert_equal([UserWarning], [w.category for w in warnings])

        with assertions.assert_warns_such_that(one_user_warning_caught):
            self._create_user_warning()
Example #8
0
    def test_passes_when_warnings_test_returns_true(self):
        """
        Test that assert_warns_such_that (used as a context manager)
        passes when the warnings_test method returns True.
        This should happen if warnings is populated correctly.
        """
        def one_user_warning_caught(warnings):
            assert_equal([UserWarning], [w.category for w in warnings])

        with assertions.assert_warns_such_that(one_user_warning_caught):
            self._create_user_warning()