1
1
from __future__ import annotations
2
2
3
- import platform
4
3
import signal
5
4
import socket
6
5
import sys
24
23
WatchFilesReload = None # type: ignore[misc,assignment]
25
24
26
25
27
- # TODO: Investigate why this is flaky on MacOS M1.
28
- skip_if_m1 = pytest .mark .skipif (
29
- sys .platform == "darwin" and platform .processor () == "arm" ,
30
- reason = "Flaky on MacOS M1" ,
31
- )
26
+ # TODO: Investigate why this is flaky on MacOS, and Windows.
27
+ skip_non_linux = pytest .mark .skipif (sys .platform in ("darwin" , "win32" ), reason = "Flaky on Windows and MacOS" )
32
28
33
29
34
30
def run (sockets : list [socket .socket ] | None ) -> None :
@@ -141,8 +137,12 @@ def test_should_not_reload_when_python_file_in_excluded_subdir_is_changed(self,
141
137
142
138
reloader .shutdown ()
143
139
144
- @pytest .mark .parametrize ("reloader_class, result" , [(StatReload , False ), (WatchFilesReload , True )])
145
- def test_reload_when_pattern_matched_file_is_changed (self , result : bool , touch_soon : Callable [[Path ], None ]):
140
+ @pytest .mark .parametrize (
141
+ "reloader_class, result" , [(StatReload , False ), pytest .param (WatchFilesReload , True , marks = skip_non_linux )]
142
+ )
143
+ def test_reload_when_pattern_matched_file_is_changed (
144
+ self , result : bool , touch_soon : Callable [[Path ], None ]
145
+ ): # pragma: py-not-linux
146
146
file = self .reload_path / "app" / "js" / "main.js"
147
147
148
148
with as_cwd (self .reload_path ):
@@ -153,10 +153,10 @@ def test_reload_when_pattern_matched_file_is_changed(self, result: bool, touch_s
153
153
154
154
reloader .shutdown ()
155
155
156
- @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_if_m1 )])
156
+ @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_non_linux )])
157
157
def test_should_not_reload_when_exclude_pattern_match_file_is_changed (
158
158
self , touch_soon : Callable [[Path ], None ]
159
- ): # pragma: py-darwin
159
+ ): # pragma: py-not-linux
160
160
python_file = self .reload_path / "app" / "src" / "main.py"
161
161
css_file = self .reload_path / "app" / "css" / "main.css"
162
162
js_file = self .reload_path / "app" / "js" / "main.js"
@@ -188,8 +188,10 @@ def test_should_not_reload_when_dot_file_is_changed(self, touch_soon: Callable[[
188
188
189
189
reloader .shutdown ()
190
190
191
- @pytest .mark .parametrize ("reloader_class" , [StatReload , WatchFilesReload ])
192
- def test_should_reload_when_directories_have_same_prefix (self , touch_soon : Callable [[Path ], None ]):
191
+ @pytest .mark .parametrize ("reloader_class" , [StatReload , pytest .param (WatchFilesReload , marks = skip_non_linux )])
192
+ def test_should_reload_when_directories_have_same_prefix (
193
+ self , touch_soon : Callable [[Path ], None ]
194
+ ): # pragma: py-not-linux
193
195
app_dir = self .reload_path / "app"
194
196
app_file = app_dir / "src" / "main.py"
195
197
app_first_dir = self .reload_path / "app_first"
@@ -210,9 +212,11 @@ def test_should_reload_when_directories_have_same_prefix(self, touch_soon: Calla
210
212
211
213
@pytest .mark .parametrize (
212
214
"reloader_class" ,
213
- [StatReload , pytest .param (WatchFilesReload , marks = skip_if_m1 )],
215
+ [StatReload , pytest .param (WatchFilesReload , marks = skip_non_linux )],
214
216
)
215
- def test_should_not_reload_when_only_subdirectory_is_watched (self , touch_soon : Callable [[Path ], None ]):
217
+ def test_should_not_reload_when_only_subdirectory_is_watched (
218
+ self , touch_soon : Callable [[Path ], None ]
219
+ ): # pragma: py-not-linux
216
220
app_dir = self .reload_path / "app"
217
221
app_dir_file = self .reload_path / "app" / "src" / "main.py"
218
222
root_file = self .reload_path / "main.py"
@@ -229,8 +233,8 @@ def test_should_not_reload_when_only_subdirectory_is_watched(self, touch_soon: C
229
233
230
234
reloader .shutdown ()
231
235
232
- @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_if_m1 )])
233
- def test_override_defaults (self , touch_soon : Callable [[Path ], None ]) -> None : # pragma: py-darwin
236
+ @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_non_linux )])
237
+ def test_override_defaults (self , touch_soon : Callable [[Path ], None ]) -> None : # pragma: py-not-linux
234
238
dotted_file = self .reload_path / ".dotted"
235
239
dotted_dir_file = self .reload_path / ".dotted_dir" / "file.txt"
236
240
python_file = self .reload_path / "main.py"
@@ -251,8 +255,8 @@ def test_override_defaults(self, touch_soon: Callable[[Path], None]) -> None: #
251
255
252
256
reloader .shutdown ()
253
257
254
- @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_if_m1 )])
255
- def test_explicit_paths (self , touch_soon : Callable [[Path ], None ]) -> None : # pragma: py-darwin
258
+ @pytest .mark .parametrize ("reloader_class" , [pytest .param (WatchFilesReload , marks = skip_non_linux )])
259
+ def test_explicit_paths (self , touch_soon : Callable [[Path ], None ]) -> None : # pragma: py-not-linux
256
260
dotted_file = self .reload_path / ".dotted"
257
261
non_dotted_file = self .reload_path / "ext" / "ext.jpg"
258
262
python_file = self .reload_path / "main.py"
0 commit comments