Skip to content

declare timeout ini options as float - #200

Merged
flub merged 1 commit into
pytest-dev:mainfrom
zxyasfas:toml-int-timeout
Aug 16, 2026
Merged

declare timeout ini options as float#200
flub merged 1 commit into
pytest-dev:mainfrom
zxyasfas:toml-int-timeout

Conversation

@zxyasfas

Copy link
Copy Markdown
Contributor

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).

@flub flub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@flub
flub merged commit cece2d6 into pytest-dev:main Aug 16, 2026
10 checks passed
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

3 participants