Author: Ronan Lamy <ronan.l...@gmail.com> Branch: Changeset: r93551:3f6df999bd4c Date: 2017-12-22 16:09 +0100 http://bitbucket.org/pypy/pypy/changeset/3f6df999bd4c/
Log: Compatibility with pytest 3.* diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_commethods.py b/pypy/module/test_lib_pypy/ctypes_tests/test_commethods.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_commethods.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_commethods.py @@ -2,10 +2,10 @@ # Can't resist from implementing some kind of mini-comtypes # theller ;-) -import py +import pytest import sys if sys.platform != "win32": - py.test.skip('windows only test') + pytest.importorskip('skip_the_whole_module') # hack! import ctypes, new, unittest from ctypes.wintypes import HRESULT @@ -27,7 +27,7 @@ if instance is None: return self return new.instancemethod(self.func, instance, owner) - + def commethod(index, restype, *argtypes): """A decorator that generates COM methods. The decorated function itself is not used except for it's name.""" @@ -72,7 +72,8 @@ assert 4 == punk.AddRef() punk.SetName("TypeLib_ByPYPY") - py.test.raises(COMError, lambda: punk.SetName(None)) + with pytest.raises(COMError): + punk.SetName(None) # This would save the typelib to disk. ## punk.SaveAllChanges() diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_init.py b/pypy/module/test_lib_pypy/ctypes_tests/test_init.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_init.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_init.py @@ -1,7 +1,6 @@ -import py +import pytest from ctypes import * -py.test.skip("subclassing semantics and implementation details not implemented") class X(Structure): _fields_ = [("a", c_int), @@ -21,19 +20,20 @@ _fields_ = [("x", X)] -class TestInit: - def test_get(self): - # make sure the only accessing a nested structure - # doesn't call the structure's __new__ and __init__ - y = Y() - assert (y.x.a, y.x.b) == (0, 0) - assert y.x.new_was_called == False +@pytest.mark.xfail( + reason="subclassing semantics and implementation details not implemented") +def test_get(): + # make sure the only accessing a nested structure + # doesn't call the structure's __new__ and __init__ + y = Y() + assert (y.x.a, y.x.b) == (0, 0) + assert y.x.new_was_called == False - # But explicitely creating an X structure calls __new__ and __init__, of course. - x = X() - assert (x.a, x.b) == (9, 12) - assert x.new_was_called == True + # But explicitely creating an X structure calls __new__ and __init__, of course. + x = X() + assert (x.a, x.b) == (9, 12) + assert x.new_was_called == True - y.x = x - assert (y.x.a, y.x.b) == (9, 12) - assert y.x.new_was_called == False + y.x = x + assert (y.x.a, y.x.b) == (9, 12) + assert y.x.new_was_called == False diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_win32.py b/pypy/module/test_lib_pypy/ctypes_tests/test_win32.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_win32.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_win32.py @@ -4,11 +4,11 @@ from ctypes.test import is_resource_enabled from support import BaseCTypesTestChecker -import py +import pytest import sys if sys.platform != "win32": - py.test.skip("win32-only tests") + pytest.importorskip('skip_the_whole_module') # hack! class TestWindows(BaseCTypesTestChecker): def test_callconv_1(self): @@ -16,13 +16,15 @@ IsWindow = windll.user32.IsWindow # ValueError: Procedure probably called with not enough arguments (4 bytes missing) - py.test.raises(ValueError, IsWindow) + with pytest.raises(ValueError): + IsWindow() # This one should succeeed... assert IsWindow(0) == 0 # ValueError: Procedure probably called with too many arguments (8 bytes in excess) - py.test.raises(ValueError, IsWindow, 0, 0, 0) + with pytest.raises(ValueError): + IsWindow(0, 0, 0) def test_callconv_2(self): # Calling stdcall function as cdecl @@ -31,13 +33,15 @@ # ValueError: Procedure called with not enough arguments (4 bytes missing) # or wrong calling convention - py.test.raises(ValueError, IsWindow, None) + with pytest.raises(ValueError): + IsWindow(None) if is_resource_enabled("SEH"): def test_SEH(self): # Call functions with invalid arguments, and make sure that access violations # are trapped and raise an exception. - py.test.raises(WindowsError, windll.kernel32.GetModuleHandleA, 32) + with pytest.raises(WindowsError): + windll.kernel32.GetModuleHandleA(32) class TestWintypes(BaseCTypesTestChecker): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit