@@ -71,6 +71,13 @@ def setUp(self):
71
71
def use_real_fs (self ):
72
72
return False
73
73
74
+ def deprecation_warning_since_313 (self ):
75
+ return (
76
+ contextlib .nullcontext ()
77
+ if sys .version_info < (3 , 13 )
78
+ else self .assertWarns (DeprecationWarning )
79
+ )
80
+
74
81
75
82
class FakePathlibInitializationTest (RealPathlibTestCase ):
76
83
def test_initialization_type (self ):
@@ -217,11 +224,7 @@ class FakePathlibPurePathTest(RealPathlibTestCase):
217
224
218
225
def test_is_reserved_posix (self ):
219
226
self .check_posix_only ()
220
- with (
221
- contextlib .nullcontext ()
222
- if sys .version_info < (3 , 13 )
223
- else self .assertWarns (DeprecationWarning )
224
- ):
227
+ with self .deprecation_warning_since_313 ():
225
228
self .assertFalse (self .path ("/dev" ).is_reserved ())
226
229
self .assertFalse (self .path ("/" ).is_reserved ())
227
230
self .assertFalse (self .path ("COM1" ).is_reserved ())
@@ -230,11 +233,7 @@ def test_is_reserved_posix(self):
230
233
@unittest .skipIf (not is_windows , "Windows specific behavior" )
231
234
def test_is_reserved_windows (self ):
232
235
self .check_windows_only ()
233
- with (
234
- contextlib .nullcontext ()
235
- if sys .version_info < (3 , 13 )
236
- else self .assertWarns (DeprecationWarning )
237
- ):
236
+ with self .deprecation_warning_since_313 ():
238
237
self .assertFalse (self .path ("/dev" ).is_reserved ())
239
238
self .assertFalse (self .path ("/" ).is_reserved ())
240
239
self .assertTrue (self .path ("COM1" ).is_reserved ())
@@ -310,11 +309,7 @@ def setUp(self):
310
309
self .path = self .pathlib .PurePosixPath
311
310
312
311
def test_is_reserved (self ):
313
- with (
314
- contextlib .nullcontext ()
315
- if sys .version_info < (3 , 13 )
316
- else self .assertWarns (DeprecationWarning )
317
- ):
312
+ with self .deprecation_warning_since_313 ():
318
313
self .assertFalse (self .path ("/dev" ).is_reserved ())
319
314
self .assertFalse (self .path ("/" ).is_reserved ())
320
315
self .assertFalse (self .path ("COM1" ).is_reserved ())
@@ -389,11 +384,7 @@ def setUp(self):
389
384
self .path = self .pathlib .PureWindowsPath
390
385
391
386
def test_is_reserved (self ):
392
- with (
393
- contextlib .nullcontext ()
394
- if sys .version_info < (3 , 13 )
395
- else self .assertWarns (DeprecationWarning )
396
- ):
387
+ with self .deprecation_warning_since_313 ():
397
388
self .assertFalse (self .path ("/dev" ).is_reserved ())
398
389
self .assertFalse (self .path ("/" ).is_reserved ())
399
390
self .assertTrue (self .path ("COM1" ).is_reserved ())
0 commit comments