1919import pytest
2020
2121from astroid import Instance , builder , nodes , test_utils , util
22- from astroid .const import IS_PYPY , PY38 , PY38_PLUS , PY39_PLUS
22+ from astroid .const import IS_PYPY , PY38 , PY38_PLUS , PY39_PLUS , PYPY_7_3_11_PLUS
2323from astroid .exceptions import (
2424 AstroidBuildingError ,
2525 AstroidSyntaxError ,
@@ -130,18 +130,18 @@ def function(
130130 def test_decorated_class_lineno () -> None :
131131 code = textwrap .dedent (
132132 """
133- class A:
133+ class A: # L2
134134 ...
135135
136136 @decorator
137- class B:
137+ class B: # L6
138138 ...
139139
140140 @deco1
141141 @deco2(
142142 var=42
143143 )
144- class C:
144+ class C: # L13
145145 ...
146146 """
147147 )
@@ -155,23 +155,15 @@ class C:
155155
156156 b = ast_module .body [1 ]
157157 assert isinstance (b , nodes .ClassDef )
158- if PY38 and IS_PYPY :
159- # Not perfect, but best we can do for PyPy 3.8
160- assert b .fromlineno == 7
161- else :
162- assert b .fromlineno == 6
158+ assert b .fromlineno == 6
163159 assert b .tolineno == 7
164160
165161 c = ast_module .body [2 ]
166162 assert isinstance (c , nodes .ClassDef )
167- if not PY38_PLUS :
168- # Not perfect, but best we can do for Python 3.7
163+ if not PY38_PLUS or IS_PYPY and PY38 and not PYPY_7_3_11_PLUS :
164+ # Not perfect, but best we can do for Python 3.7 and PyPy 3.8 (< v7.3.11).
169165 # Can't detect closing bracket on new line.
170166 assert c .fromlineno == 12
171- elif PY38 and IS_PYPY :
172- # Not perfect, but best we can do for PyPy 3.8
173- # Can't detect closing bracket on new line.
174- assert c .fromlineno == 16
175167 else :
176168 assert c .fromlineno == 13
177169 assert c .tolineno == 14
0 commit comments