Last active
March 6, 2017 12:07
-
-
Save danodonovan/042e1c74ea76cbea39b42f5c8733ede0 to your computer and use it in GitHub Desktop.
PyHamcrest not catching SystemExit exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import unittest | |
from hamcrest import assert_that, calling, raises | |
import pytest | |
def call_exit(): | |
sys.exit() | |
class TestUnittest(unittest.TestCase): | |
def test_exits(self): | |
with self.assertRaises(SystemExit): | |
call_exit() | |
def test_pytest(): | |
with pytest.raises(SystemExit): | |
call_exit() | |
def test_hamcrest(): | |
assert_that(calling(call_exit), raises(SystemExit)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results in test
test_hamcrest
tests failing (and others passing).