@@ -1569,16 +1569,17 @@ def test_exit_reason_only():
15691569 result .stdout .fnmatch_lines ("*_pytest.outcomes.Exit: foo*" )
15701570
15711571
1572- @ pytest . mark . parametrize (
1573- "reason " ,
1574- [
1575- "sys.version_info < (3, 6) " ,
1576- "sys.platform.startswith('win')" ,
1577- "os.name == 'nt'" ,
1578- ],
1579- )
1572+ SUSPECT_REASONS = [
1573+ "sys.version_info < (3, 6) " ,
1574+ "sys.platform.startswith('win')" ,
1575+ "os.name == 'nt' " ,
1576+ ]
1577+
1578+
1579+ @ pytest . mark . parametrize ( "reason" , SUSPECT_REASONS )
15801580def test_skip_reason_looks_like_condition_warns (
1581- pytester : Pytester , reason : str
1581+ pytester : Pytester ,
1582+ reason : str ,
15821583) -> None :
15831584 pytester .makepyfile (
15841585 f"""
@@ -1591,11 +1592,32 @@ def test_func():
15911592 )
15921593 result = pytester .runpytest ("-W" , "default::pytest.PytestWarning" )
15931594 result .stdout .fnmatch_lines (
1594- ["*looks like a condition*Did you mean pytest.mark.skipif?" ]
1595+ [
1596+ "*looks like a condition*Did you mean pytest.mark.skipif ?" ,
1597+ "*If intentional, pass reason as a keyword argument to disable this warning." ,
1598+ ]
15951599 )
15961600 result .assert_outcomes (skipped = 1 , warnings = 1 )
15971601
15981602
1603+ @pytest .mark .parametrize ("reason" , SUSPECT_REASONS )
1604+ def test_skip_reason_looks_like_condition_kwarg (
1605+ pytester : Pytester ,
1606+ reason : str ,
1607+ ) -> None :
1608+ pytester .makepyfile (
1609+ f"""
1610+ import pytest
1611+
1612+ @pytest.mark.skip({ reason = !r} )
1613+ def test_func():
1614+ pass
1615+ """
1616+ )
1617+ result = pytester .runpytest ("-W" , "default::pytest.PytestWarning" )
1618+ result .assert_outcomes (skipped = 1 , warnings = 0 )
1619+
1620+
15991621@pytest .mark .parametrize (
16001622 "reason" ,
16011623 [
0 commit comments