1
1
# stdlib
2
2
import ast
3
+ import sys
3
4
from typing import Set
4
5
5
6
# 3rd party
@@ -13,6 +14,7 @@ def results(s: str) -> Set[str]:
13
14
return {"{}:{}: {}" .format (* r ) for r in Plugin (ast .parse (s )).run ()}
14
15
15
16
17
+ @pytest .mark .skipif (sys .version_info >= (3 , 12 ), reason = "Line numbers are offset on earlier versions" )
16
18
def test_linux_specific ():
17
19
assert results ('print(f"{now:%Y/%-m/%-d %H:%M}")' ) == { # noqa: STRFTIME001
18
20
"1:9: STRFTIME001 Linux-specific strftime code used." ,
@@ -25,6 +27,20 @@ def test_linux_specific():
25
27
}
26
28
27
29
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" )
28
44
def test_windows_specific ():
29
45
assert results ('print(f"{now:%Y/%#m/%#d %H:%M}")' ) == { # noqa: STRFTIME002
30
46
"1:9: STRFTIME002 Windows-specific strftime code used." ,
@@ -37,6 +53,19 @@ def test_windows_specific():
37
53
}
38
54
39
55
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
+
40
69
@pytest .mark .parametrize (
41
70
"source" ,
42
71
[
0 commit comments