Skip to content

Commit 5ecb4df

Browse files
tests: retry network tests (#369)
1 parent 978501b commit 5ecb4df

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎dev-requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ twine<=5.0.0
33
wheel
44
ruff==0.6.6
55
pytest==7.4.0
6+
pytest-rerunfailures==13.0
67
coverage==6.5.0
78
pytest-subprocess==1.5.0
89

‎tests/test_main.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import TYPE_CHECKING
1010
from pathlib import Path
1111

12+
import pytest
1213
from packaging import version
1314

1415
import pyright
@@ -23,6 +24,8 @@
2324

2425
VERSION_REGEX = re.compile(r'pyright (?P<version>\d+\.\d+\.\d+)')
2526

27+
network = pytest.mark.flaky(reruns=2, reruns_delay=2)
28+
2629

2730
def test_module_invocation() -> None:
2831
proc = subprocess.run(
@@ -35,6 +38,7 @@ def test_module_invocation() -> None:
3538
assert match.group(1) == __pyright_version__
3639

3740

41+
@network
3842
def test_module_invocation_version() -> None:
3943
proc = subprocess.run(
4044
[sys.executable, '-m', 'pyright', '--version'],
@@ -47,6 +51,7 @@ def test_module_invocation_version() -> None:
4751
assert match.group(1) == '1.1.223'
4852

4953

54+
@network
5055
def test_module_invocation_latest_version() -> None:
5156
proc = subprocess.run(
5257
[sys.executable, '-m', 'pyright', '--version'],
@@ -59,6 +64,7 @@ def test_module_invocation_latest_version() -> None:
5964
assert version.parse(match.group(1)) >= version.parse(__pyright_version__)
6065

6166

67+
@network
6268
def test_module_invocation_pylance_version() -> None:
6369
proc = subprocess.run(
6470
[sys.executable, '-m', 'pyright', '--version'],
@@ -71,6 +77,7 @@ def test_module_invocation_pylance_version() -> None:
7177
assert match.group(1) == '1.1.334'
7278

7379

80+
@network
7481
def test_module_invocation_pylance_version_latest_prerelease() -> None:
7582
proc = subprocess.run(
7683
[sys.executable, '-m', 'pyright', '--version'],
@@ -120,6 +127,7 @@ def test_argument_separator(tmp_path: Path) -> None:
120127
assert 'does not exist' not in output
121128

122129

130+
@network
123131
def test_explicit_version_new_version_warning() -> None:
124132
"""A new version is available warning is emitted explicitly using an older version"""
125133
proc = subprocess.run(
@@ -133,6 +141,7 @@ def test_explicit_version_new_version_warning() -> None:
133141
assert 'WARNING: there is a new pyright version available' in output
134142

135143

144+
@network
136145
def test_explicit_latest_no_new_version_warning() -> None:
137146
"""No new version warning is emitted when explicitly setting to `latest`"""
138147
proc = subprocess.run(
@@ -146,6 +155,7 @@ def test_explicit_latest_no_new_version_warning() -> None:
146155
assert 'WARNING: there is a new pyright version available' not in output
147156

148157

158+
@network
149159
def test_pylance_version_no_new_version_warning() -> None:
150160
"""No new version warning is emitted when PYRIGHT_PYTHON_PYLANCE_VERSION is set"""
151161
proc = subprocess.run(
@@ -159,6 +169,7 @@ def test_pylance_version_no_new_version_warning() -> None:
159169
assert 'WARNING: there is a new pyright version available' not in output
160170

161171

172+
@network
162173
def test_output_json_no_warning() -> None:
163174
"""If the --outputjson flag is set then no warning is emitted"""
164175
proc = subprocess.run(
@@ -172,6 +183,7 @@ def test_output_json_no_warning() -> None:
172183
assert 'WARNING: there is a new pyright version available' not in output
173184

174185

186+
@network
175187
def test_ignore_warnings_config_no_warning() -> None:
176188
"""If the --outputjson flag is set then no warning is emitted"""
177189
proc = subprocess.run(
@@ -189,6 +201,7 @@ def test_ignore_warnings_config_no_warning() -> None:
189201
assert 'WARNING: there is a new pyright version available' not in output
190202

191203

204+
@network
192205
def test_nodeenv() -> None:
193206
"""Ensure nodeenv is successfully downloaded and used"""
194207
subprocess.run(

0 commit comments

Comments
 (0)