diff --git a/testing/code/test_assertionnew.py b/testing/code/test_assertionnew.py deleted file mode 100644 index 8511f8125..000000000 --- a/testing/code/test_assertionnew.py +++ /dev/null @@ -1,44 +0,0 @@ -import sys - -import py -from py._code._assertionnew import interpret - - -def getframe(): - """Return the frame of the caller as a py.code.Frame object""" - return py.code.Frame(sys._getframe(1)) - - -def pytest_funcarg__hook(request): - class MockHook(object): - def __init__(self): - self.called = False - self.args = tuple() - self.kwargs = dict() - - def __call__(self, op, left, right): - self.called = True - self.op = op - self.left = left - self.right = right - return MockHook() - - -def test_pytest_assert_compare_called(monkeypatch, hook): - monkeypatch.setattr(py._plugin.pytest_assertion, - 'pytest_assert_compare', hook) - interpret('assert 0 == 1', getframe()) - assert hook.called - - -def test_pytest_assert_compare_args(monkeypatch, hook): - print hook.called - monkeypatch.setattr(py._plugin.pytest_assertion, - 'pytest_assert_compare', hook) - interpret('assert [0, 1] == [0, 2]', getframe()) - print hook.called - print hook.left - print hook.right - assert hook.op == '==' - assert hook.left == [0, 1] - assert hook.right == [0, 2] diff --git a/testing/plugin/test_pytest_assertion.py b/testing/plugin/test_pytest_assertion.py index 9ab007f29..596de0050 100644 --- a/testing/plugin/test_pytest_assertion.py +++ b/testing/plugin/test_pytest_assertion.py @@ -1,7 +1,30 @@ +import sys + import py +from py._code._assertionnew import interpret import py._plugin.pytest_assertion as plugin +def getframe(): + """Return the frame of the caller as a py.code.Frame object""" + return py.code.Frame(sys._getframe(1)) + + +def pytest_funcarg__hook(request): + class MockHook(object): + def __init__(self): + self.called = False + self.args = tuple() + self.kwargs = dict() + + def __call__(self, op, left, right): + self.called = True + self.op = op + self.left = left + self.right = right + return MockHook() + + def test_functional(testdir): testdir.makepyfile(""" def test_hello(): @@ -54,7 +77,27 @@ def test_traceback_failure(testdir): ]) -class Test_pytest_assert_compare: +def test_pytest_assert_compare_called(monkeypatch, hook): + monkeypatch.setattr(py._plugin.pytest_assertion, + 'pytest_assert_compare', hook) + interpret('assert 0 == 1', getframe()) + assert hook.called + + +def test_pytest_assert_compare_args(monkeypatch, hook): + print hook.called + monkeypatch.setattr(py._plugin.pytest_assertion, + 'pytest_assert_compare', hook) + interpret('assert [0, 1] == [0, 2]', getframe()) + print hook.called + print hook.left + print hook.right + assert hook.op == '==' + assert hook.left == [0, 1] + assert hook.right == [0, 2] + + +class TestAssertCompare: def test_different_types(self): assert plugin.pytest_assert_compare('==', [0, 1], 'foo') is None