From 894e300841ee532328b0b623a68344262af2ac97 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 26 Oct 2022 14:33:33 +0200 Subject: [PATCH] Remove dependency on py lib The py dependency has been removed in pytest: https://github.com/pytest-dev/pytest/pull/10396 --- pytest_odoo.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pytest_odoo.py b/pytest_odoo.py index 2135e75..4379c26 100644 --- a/pytest_odoo.py +++ b/pytest_odoo.py @@ -14,10 +14,13 @@ import _pytest import _pytest.python -import py.code -import py.error import pytest +from _pytest._code.code import ExceptionInfo +import _pytest._py.error as error + +from pathlib import Path + import odoo import odoo.tests @@ -144,13 +147,14 @@ def _importtestmodule(self): modfile = modfile[:-12] try: issame = self.fspath.samefile(modfile) - except py.error.ENOENT: + except error.ENOENT: issame = False if not issame: raise self.fspath.ImportMismatchError(modname, modfile, self) - except SyntaxError: + except SyntaxError as e: raise self.CollectError( - py.code.ExceptionInfo().getrepr(style="short")) + ExceptionInfo.from_current().getrepr(style="short") + ) from e except self.fspath.ImportMismatchError: e = sys.exc_info()[1] raise self.CollectError(