Skip to content

declare timeout ini options as float - #200

Open
zxyasfas wants to merge 1 commit into
pytest-dev:mainfrom
zxyasfas:toml-int-timeout
Open

declare timeout ini options as float#200
zxyasfas wants to merge 1 commit into
pytest-dev:mainfrom
zxyasfas:toml-int-timeout

Conversation

@zxyasfas

Copy link
Copy Markdown

Fixes #194.

With pytest 9's native [tool.pytest] table, timeout = 1200 (a TOML int) makes the whole session die at configure time:

INTERNALERROR> TypeError: pyproject.toml: config option 'timeout' expects a string, got int: 1200

because timeout and session_timeout are registered with the default string ini type. Registering them with type="float" fixes it, matching what the values actually are. Legacy [pytest] ini strings like timeout = 2.5 still parse the same way, and timeout = 0 still means disabled (the > 0 checks are unchanged).

One catch: type="float" was added to addini in pytest 8.4, and registering it under 8.0.x fails at plugin load, so this bumps the floor in setup.cfg to pytest>=8.4.0. If keeping 8.0 support matters more, the alternative is a try/except shim around the registration; happy to switch if you prefer that.

Added a regression test using makepyprojecttoml with int values for both options (skipped below pytest 9, where the native table doesn't exist). Suite passes locally on 3.12: 35 passed, 21 skipped (the pexpect spawn skips, this is a Windows machine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: /path/to/pyproject.toml: config option 'timeout' expects a string, got int: 1200 in pytest 9.0

1 participant