Skip to content

Commit 9e22638

Browse files
committed
Allow different test output for different Python versions
1 parent 1257474 commit 9e22638

6 files changed

+24
-24
lines changed

pylint/testutils/functional/test_file.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from __future__ import annotations
66

77
import configparser
8+
import os
9+
import sys
810
from collections.abc import Callable
911
from os.path import basename, exists, join
1012
from typing import TypedDict
@@ -99,7 +101,23 @@ def module(self) -> str:
99101

100102
@property
101103
def expected_output(self) -> str:
102-
return self._file_type(".txt", check_exists=False)
104+
files = list(
105+
filter(
106+
lambda s: s.startswith(self.base) and s.endswith(".txt"),
107+
os.listdir(self._directory),
108+
)
109+
)
110+
# pylint: disable-next=bad-builtin
111+
current_version = int("".join(map(str, sys.version_info[:2])))
112+
output_options = [
113+
int(version)
114+
for s in files
115+
if s.count(".") == 2 and (version := s.rsplit(".", maxsplit=2)[1]).isalnum()
116+
]
117+
for opt in sorted(output_options, reverse=True):
118+
if current_version >= opt:
119+
return join(self._directory, f"{self.base}.{opt}.txt")
120+
return join(self._directory, self.base + ".txt")
103121

104122
@property
105123
def source(self) -> str:

tests/functional/ext/typing/unnecessary_default_type_args.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import typing as t
44

55
a1: t.Generator[int, str, str]
6-
a2: t.Generator[int, None, None]
6+
a2: t.Generator[int, None, None] # >=3.13:[unnecessary-default-type-args]
77
a3: t.Generator[int]
88
b1: t.AsyncGenerator[int, str]
9-
b2: t.AsyncGenerator[int, None]
9+
b2: t.AsyncGenerator[int, None] # >=3.13:[unnecessary-default-type-args]
1010
b3: t.AsyncGenerator[int]
1111

1212
c1: ca.Generator[int, str, str]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
[main]
2-
py-version=3.10
32
load-plugins=pylint.extensions.typing
3+
4+
[testoptions]
5+
min_pyver=3.10

tests/functional/ext/typing/unnecessary_default_type_args_py313.py

-17
This file was deleted.

tests/functional/ext/typing/unnecessary_default_type_args_py313.rc

-3
This file was deleted.

0 commit comments

Comments
 (0)