Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.13 (beta) support #12334

Merged
merged 2 commits into from
May 19, 2024
Merged

Add Python 3.13 (beta) support #12334

merged 2 commits into from
May 19, 2024

Conversation

bluetech
Copy link
Member

Fix #12323

@@ -289,7 +289,8 @@ def assert_contains(self, entries: Sequence[Tuple[str, str]]) -> None:
__tracebackhide__ = True
i = 0
entries = list(entries)
backlocals = sys._getframe(1).f_locals
# Since Python 3.13, f_locals is not a dict, but eval requires a dict.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -760,6 +761,9 @@ def _makefile(
) -> Path:
items = list(files.items())

if ext is None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluetech
Copy link
Member Author

One remaining failure, on windows:

 ________________________ test_cache_reportheader[env1] ________________________

env = ('TOX_ENV_DIR', '/tox_env_dir')
pytester = <Pytester WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-unknown/pytest-0/test_cache_reportheader1')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000209B926A120>

    @pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "/tox_env_dir")))
    def test_cache_reportheader(
        env: Sequence[str], pytester: Pytester, monkeypatch: MonkeyPatch
    ) -> None:
        pytester.makepyfile("""def test_foo(): pass""")
        if env:
            monkeypatch.setenv(*env)
            expected = os.path.join(env[1], ".pytest_cache")
        else:
            monkeypatch.delenv("TOX_ENV_DIR", raising=False)
            expected = ".pytest_cache"
        result = pytester.runpytest("-v")
>       result.stdout.fnmatch_lines([f"cachedir: {expected}"])
E       Failed: nomatch: 'cachedir: /tox_env_dir\\.pytest_cache'
E           and: '============================= test session starts ============================='
E           and: 'platform win32 -- Python 3.13.0b1, pytest-8.3.0.dev49+g87c7a72ce, pluggy-1.5.0 -- D:\\a\\pytest\\pytest\\.tox\\py313\\Scripts\\python.EXE'
E           and: 'cachedir: C:\\tox_env_dir\\.pytest_cache'
E           and: 'rootdir: C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-unknown\\pytest-0\\test_cache_reportheader1'
E           and: 'collecting ... collected 1 item'
E           and: ''
E           and: 'test_cache_reportheader.py::test_foo PASSED                              [100%]'
E           and: ''
E           and: '============================== 1 passed in 0.01s =============================='
E       remains unmatched: 'cachedir: /tox_env_dir\\.pytest_cache'

Probably something in os.path/pathlib changed.

@RonnyPfannschmidt
Copy link
Member

Seems like its normalized/resolved now, so the env name is no longer correct

No need to support beta releases of an older version anymore.

Ref: 09b2c95
@bluetech
Copy link
Member Author

I don't know if the C:\ is correct or not, and I don't have windows handy, but since it's only for display, and probably tox doesn't issue such env dir path on windows anyway, so decided to sidestep the issue in the test.

This is ready for review, I'll also backport it for 8.2.1.

@bluetech bluetech marked this pull request as ready for review May 18, 2024 16:55
@bluetech bluetech changed the title WIP: Add Python 3.13 (beta) support Add Python 3.13 (beta) support May 18, 2024
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for tackling this!

@@ -760,6 +761,9 @@ def _makefile(
) -> Path:
items = list(files.items())

if ext is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave a note here:

Suggested change
if ext is None:
# https://github.com/python/cpython/issues/119113
if ext is None:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary, since I think we better not rely on it and just keep the check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see what harm a small comment like that could cause either, but OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in that case, we probably should change the signature as well, so we have the typing match the runtime behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is ext: str which is correct. The callers have some *args, **kwargs forwarding which is somewhat annoying to type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well OK, this is no big deal anyway.

@@ -373,7 +374,10 @@ def test_excinfo_no_sourcecode():
except ValueError:
excinfo = _pytest._code.ExceptionInfo.from_current()
s = str(excinfo.traceback[-1])
assert s == " File '<string>':1 in <module>\n ???\n"
# TODO: Since Python 3.13b1 under pytest-xdist, the * is `import
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

@@ -0,0 +1 @@
Support for Python 3.13 (beta1 at the time of writing).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would categorize this as a feature actually.

@bluetech bluetech merged commit c1d623c into pytest-dev:main May 19, 2024
27 checks passed
@bluetech bluetech deleted the py313 branch May 19, 2024 06:45
@bluetech bluetech added the backport 8.2.x Apply on merged PRs, backports the changes to the 8.2.x branch label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.2.x Apply on merged PRs, backports the changes to the 8.2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failures on Python 3.13.0b1
3 participants