99from typing import TYPE_CHECKING
1010from pathlib import Path
1111
12+ import pytest
1213from packaging import version
1314
1415import pyright
2324
2425VERSION_REGEX = re .compile (r'pyright (?P<version>\d+\.\d+\.\d+)' )
2526
27+ network = pytest .mark .flaky (reruns = 2 , reruns_delay = 2 )
28+
2629
2730def 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
3842def 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
5055def 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
6268def 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
7481def 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
123131def 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
136145def 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
149159def 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
162173def 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
175187def 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
192205def test_nodeenv () -> None :
193206 """Ensure nodeenv is successfully downloaded and used"""
194207 subprocess .run (
0 commit comments