11# stdlib
22import ast
3+ import sys
34from typing import Set
45
56# 3rd party
@@ -13,6 +14,7 @@ def results(s: str) -> Set[str]:
1314 return {"{}:{}: {}" .format (* r ) for r in Plugin (ast .parse (s )).run ()}
1415
1516
17+ @pytest .mark .skipif (sys .version_info >= (3 , 12 ), reason = "Line numbers are offset on earlier versions" )
1618def test_linux_specific ():
1719 assert results ('print(f"{now:%Y/%-m/%-d %H:%M}")' ) == { # noqa: STRFTIME001
1820 "1:9: STRFTIME001 Linux-specific strftime code used." ,
@@ -25,6 +27,20 @@ def test_linux_specific():
2527 }
2628
2729
30+ @pytest .mark .skipif (sys .version_info < (3 , 12 ), reason = "Line numbers are offset on earlier versions" )
31+ def test_linux_specific_312 ():
32+ assert results ('print(f"{now:%Y/%-m/%-d %H:%M}")' ) == { # noqa: STRFTIME001
33+ "1:16: STRFTIME001 Linux-specific strftime code used." ,
34+ "1:20: STRFTIME001 Linux-specific strftime code used." ,
35+ }
36+
37+ assert results ('print(now.strftime("%Y/%-m/%-d %H:%M"))' ) == { # noqa: STRFTIME001
38+ "1:22: STRFTIME001 Linux-specific strftime code used." ,
39+ "1:26: STRFTIME001 Linux-specific strftime code used." ,
40+ }
41+
42+
43+ @pytest .mark .skipif (sys .version_info >= (3 , 12 ), reason = "Line numbers are offset on earlier versions" )
2844def test_windows_specific ():
2945 assert results ('print(f"{now:%Y/%#m/%#d %H:%M}")' ) == { # noqa: STRFTIME002
3046 "1:9: STRFTIME002 Windows-specific strftime code used." ,
@@ -37,6 +53,19 @@ def test_windows_specific():
3753 }
3854
3955
56+ @pytest .mark .skipif (sys .version_info < (3 , 12 ), reason = "Line numbers are offset on earlier versions" )
57+ def test_windows_specific_312 ():
58+ assert results ('print(f"{now:%Y/%#m/%#d %H:%M}")' ) == { # noqa: STRFTIME002
59+ "1:16: STRFTIME002 Windows-specific strftime code used." ,
60+ "1:20: STRFTIME002 Windows-specific strftime code used." ,
61+ }
62+
63+ assert results ('print(now.strftime("%Y/%#m/%#d %H:%M"))' ) == { # noqa: STRFTIME002
64+ "1:22: STRFTIME002 Windows-specific strftime code used." ,
65+ "1:26: STRFTIME002 Windows-specific strftime code used." ,
66+ }
67+
68+
4069@pytest .mark .parametrize (
4170 "source" ,
4271 [
0 commit comments