Skip to content

Avoid deprecated pytest.warns(None) #2548

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

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import re
import sys
import warnings
from textwrap import dedent

import py
Expand Down Expand Up @@ -2469,7 +2470,8 @@ def get_executable(self, envconfig):

major, minor = sys.version_info[0:2]

with pytest.warns(None) as lying:
with warnings.catch_warnings():
warnings.simplefilter("error")
config = newconfig(
"""
[testenv:py{0}]
Expand All @@ -2483,9 +2485,9 @@ def get_executable(self, envconfig):

env_config = config.envconfigs["py{}".format(major)]
assert env_config.basepython == "python{}.{}".format(major, minor - 1)
assert len(lying) == 0, "\n".join(repr(r.message) for r in lying)

with pytest.warns(None) as truthful:
with warnings.catch_warnings():
warnings.simplefilter("error")
config = newconfig(
"""
[testenv:py{0}]
Expand All @@ -2499,10 +2501,10 @@ def get_executable(self, envconfig):

env_config = config.envconfigs["py{}".format(major)]
assert env_config.basepython == "python{}.{}".format(major, minor)
assert len(truthful) == 0, "\n".join(repr(r.message) for r in truthful)

def test_default_factors_conflict_ignore(self, newconfig, capsys):
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
config = newconfig(
"""
[tox]
Expand All @@ -2516,7 +2518,6 @@ def test_default_factors_conflict_ignore(self, newconfig, capsys):
assert len(config.envconfigs) == 1
envconfig = config.envconfigs["py27"]
assert envconfig.basepython == "python2.7"
assert len(record) == 0, "\n".join(repr(r.message) for r in record)

def test_factors_in_boolean(self, newconfig):
inisource = """
Expand Down