Skip to content

Commit c6f671b

Browse files
Fix tests for Python 3.11 (#7167)
* Ignore deprecated-module in access_attr_before_def_false_positive This is because telnetlib is deprecated in Python 3.11. It's hard to see exactly what this is testing - there's no great explanation in-line and the test predates the first commit to the git repo so we don't have a commit message to help. telnetlib will be removed in 3.13, though, so at that point we'll have to figure it out or drop the telnetlib part of the test. Signed-off-by: Adam Williamson <[email protected]> * Split asyncio.coroutine tests and set max_pyver 3.10 for them iterable_context_py3 includes some checks that we don't emit errors for asyncio.coroutine, but asyncio.coroutine has been removed in Python 3.11, so we need to set a max version of 3.10 for these tests. Signed-off-by: Adam Williamson <[email protected]> * Set max_pyver 3.10 for some deprecations removed in 3.11 The `binhex` module and `binascii.b2a_hqx()` function, which were deprecated in 3.9, are removed entirely in 3.11. Signed-off-by: Adam Williamson <[email protected]> * Change syntax_error test for consistent output Python 3.11 changes the string representation of the SyntaxError triggered by this test - it now says "expected '('" instead of just "invalid syntax". This changes the test to use a different error (incomplete `for` loop) which still has just "invalid syntax" as its description in Python 3.11. This is the same 'bad code' used in the similar `test_stdin_syntaxerror` in the unit tests. Signed-off-by: Adam Williamson <[email protected]> Co-authored-by: Daniël van Noord <[email protected]>
1 parent 4430e19 commit c6f671b

9 files changed

+51
-40
lines changed

tests/functional/a/access/access_attr_before_def_false_positive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pylint: disable=invalid-name,too-many-public-methods,attribute-defined-outside-init
2-
# pylint: disable=useless-object-inheritance,too-few-public-methods
2+
# pylint: disable=useless-object-inheritance,too-few-public-methods,deprecated-module
33
"""This module demonstrates a possible problem of pyLint with calling __init__ s
44
from inherited classes.
55
Initializations done there are not considered, which results in Error E0203 for
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[testoptions]
22
min_pyver=3.9
3+
max_pyver=3.10
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[testoptions]
22
min_pyver=3.9
3+
max_pyver=3.10

tests/functional/d/deprecated/deprecated_module_py39_earlier_pyversion.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ py-version=3.8
33

44
[testoptions]
55
min_pyver=3.9
6+
max_pyver=3.10
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Checks that we don't erroneously emit not-an-iterable errors for
3+
coroutines built with asyncio.coroutine.
4+
5+
These decorators were deprecated in 3.8 and removed in 3.11.
6+
"""
7+
# pylint: disable=missing-docstring,too-few-public-methods,unused-argument,bad-mcs-method-argument
8+
# pylint: disable=wrong-import-position
9+
import asyncio
10+
11+
12+
@asyncio.coroutine
13+
def coroutine_function_return_none():
14+
return
15+
16+
17+
@asyncio.coroutine
18+
def coroutine_function_return_object():
19+
return 12
20+
21+
22+
@asyncio.coroutine
23+
def coroutine_function_return_future():
24+
return asyncio.Future()
25+
26+
27+
@asyncio.coroutine
28+
def coroutine_function_pass():
29+
pass
30+
31+
32+
@asyncio.coroutine
33+
def coroutine_generator():
34+
yield
35+
36+
37+
@asyncio.coroutine
38+
def main():
39+
yield from coroutine_function_return_none()
40+
yield from coroutine_function_return_object()
41+
yield from coroutine_function_return_future()
42+
yield from coroutine_function_pass()
43+
yield from coroutine_generator()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testoptions]
2+
max_pyver=3.10

tests/functional/i/iterable_context_py3.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,3 @@ class SomeClass(metaclass=Meta):
1616
print(i)
1717
for i in SomeClass(): # [not-an-iterable]
1818
print(i)
19-
20-
21-
import asyncio
22-
23-
24-
@asyncio.coroutine
25-
def coroutine_function_return_none():
26-
return
27-
28-
29-
@asyncio.coroutine
30-
def coroutine_function_return_object():
31-
return 12
32-
33-
34-
@asyncio.coroutine
35-
def coroutine_function_return_future():
36-
return asyncio.Future()
37-
38-
39-
@asyncio.coroutine
40-
def coroutine_function_pass():
41-
pass
42-
43-
44-
@asyncio.coroutine
45-
def coroutine_generator():
46-
yield
47-
48-
49-
@asyncio.coroutine
50-
def main():
51-
yield from coroutine_function_return_none()
52-
yield from coroutine_function_return_object()
53-
yield from coroutine_function_return_future()
54-
yield from coroutine_function_pass()
55-
yield from coroutine_generator()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
def toto # [syntax-error]
1+
for # [syntax-error]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
syntax-error:1:10:None:None::invalid syntax (<unknown>, line 1):UNDEFINED
1+
syntax-error:1:5:None:None::invalid syntax (<unknown>, line 1):UNDEFINED

0 commit comments

Comments
 (0)