@@ -49,12 +49,12 @@ def get_dummy_application(role: str) -> AppDef:
49
49
return AppDef (name = "test_app" , roles = [trainer ])
50
50
51
51
52
- def test_empty_fn () -> AppDef :
52
+ def example_empty_fn () -> AppDef :
53
53
"""Empty function that returns dummy app"""
54
54
return get_dummy_application ("trainer" )
55
55
56
56
57
- def test_fn_with_bool (flag : bool = False ) -> AppDef :
57
+ def example_fn_with_bool (flag : bool = False ) -> AppDef :
58
58
"""Dummy app with or without flag
59
59
60
60
Args:
@@ -66,7 +66,7 @@ def test_fn_with_bool(flag: bool = False) -> AppDef:
66
66
return get_dummy_application ("trainer-without-flag" )
67
67
68
68
69
- def test_fn_with_bool_optional (flag : Optional [bool ] = None ) -> AppDef :
69
+ def example_fn_with_bool_optional (flag : Optional [bool ] = None ) -> AppDef :
70
70
"""Dummy app with or without flag
71
71
72
72
Args:
@@ -78,11 +78,11 @@ def test_fn_with_bool_optional(flag: Optional[bool] = None) -> AppDef:
78
78
return get_dummy_application ("trainer-without-flag" )
79
79
80
80
81
- def test_empty_fn_no_docstring () -> AppDef :
81
+ def example_empty_fn_no_docstring () -> AppDef :
82
82
return get_dummy_application ("trainer" )
83
83
84
84
85
- def _test_complex_fn (
85
+ def example_test_complex_fn (
86
86
app_name : str ,
87
87
containers : List [str ],
88
88
roles_scripts : Dict [str , str ],
@@ -133,7 +133,7 @@ def _test_complex_fn(
133
133
_TEST_VAR_ARGS : Optional [Tuple [object , ...]] = None
134
134
135
135
136
- def _test_var_args (foo : str , * args : str , bar : str = "asdf" ) -> AppDef :
136
+ def example_var_args (foo : str , * args : str , bar : str = "asdf" ) -> AppDef :
137
137
"""
138
138
test component for mixing var args with kwargs.
139
139
Args:
@@ -149,7 +149,7 @@ def _test_var_args(foo: str, *args: str, bar: str = "asdf") -> AppDef:
149
149
_TEST_VAR_ARGS_FIRST : Optional [Tuple [object , ...]] = None
150
150
151
151
152
- def _test_var_args_first (* args : str , bar : str = "asdf" ) -> AppDef :
152
+ def example_var_args_first (* args : str , bar : str = "asdf" ) -> AppDef :
153
153
"""
154
154
test component for mixing var args with kwargs.
155
155
Args:
@@ -164,7 +164,7 @@ def _test_var_args_first(*args: str, bar: str = "asdf") -> AppDef:
164
164
_TEST_SINGLE_LETTER : Optional [str ] = None
165
165
166
166
167
- def _test_single_letter (c : str ) -> AppDef :
167
+ def example_single_letter (c : str ) -> AppDef :
168
168
global _TEST_SINGLE_LETTER
169
169
_TEST_SINGLE_LETTER = c
170
170
return AppDef (name = "varargs" )
@@ -182,7 +182,7 @@ def _get_nested_arg(self) -> Dict[str, List[str]]:
182
182
183
183
def _get_expected_app_with_default (self ) -> AppDef :
184
184
role_args = self ._get_role_args ()
185
- return _test_complex_fn (
185
+ return example_test_complex_fn (
186
186
"test_app" ,
187
187
["img1" , "img2" ],
188
188
{"worker" : "worker.py" , "master" : "master.py" },
@@ -209,7 +209,7 @@ def _get_args_with_default(self) -> List[str]:
209
209
210
210
def _get_expected_app_with_all_args (self ) -> AppDef :
211
211
role_args = self ._get_role_args ()
212
- return _test_complex_fn (
212
+ return example_test_complex_fn (
213
213
"test_app" ,
214
214
["img1" , "img2" ],
215
215
{"worker" : "worker.py" , "master" : "master.py" },
@@ -245,7 +245,7 @@ def _get_app_args(self) -> List[str]:
245
245
def _get_expected_app_with_nested_objects (self ) -> AppDef :
246
246
role_args = self ._get_role_args ()
247
247
defaults = self ._get_nested_arg ()
248
- return _test_complex_fn (
248
+ return example_test_complex_fn (
249
249
"test_app" ,
250
250
["img1" , "img2" ],
251
251
{"worker" : "worker.py" , "master" : "master.py" },
@@ -282,20 +282,20 @@ def _get_app_args_and_defaults_with_nested_objects(
282
282
], defaults
283
283
284
284
def test_load_from_fn_empty (self ) -> None :
285
- actual_app = materialize_appdef (test_empty_fn , [])
285
+ actual_app = materialize_appdef (example_empty_fn , [])
286
286
expected_app = get_dummy_application ("trainer" )
287
287
self .assert_apps (expected_app , actual_app )
288
288
289
289
def test_load_from_fn_complex_all_args (self ) -> None :
290
290
expected_app = self ._get_expected_app_with_all_args ()
291
291
app_args = self ._get_app_args ()
292
- actual_app = materialize_appdef (_test_complex_fn , app_args )
292
+ actual_app = materialize_appdef (example_test_complex_fn , app_args )
293
293
self .assert_apps (expected_app , actual_app )
294
294
295
295
def test_required_args (self ) -> None :
296
296
with patch .object (sys , "exit" ) as exit_mock :
297
297
try :
298
- materialize_appdef (_test_complex_fn , [])
298
+ materialize_appdef (example_test_complex_fn , [])
299
299
except Exception :
300
300
# ignore any errors, since function should fail
301
301
pass
@@ -304,18 +304,18 @@ def test_required_args(self) -> None:
304
304
def test_load_from_fn_with_default (self ) -> None :
305
305
expected_app = self ._get_expected_app_with_default ()
306
306
app_args = self ._get_args_with_default ()
307
- actual_app = materialize_appdef (_test_complex_fn , app_args )
307
+ actual_app = materialize_appdef (example_test_complex_fn , app_args )
308
308
self .assert_apps (expected_app , actual_app )
309
309
310
310
def test_with_nested_object (self ) -> None :
311
311
expected_app = self ._get_expected_app_with_nested_objects ()
312
312
app_args , defaults = self ._get_app_args_and_defaults_with_nested_objects ()
313
- actual_app = materialize_appdef (_test_complex_fn , app_args , defaults )
313
+ actual_app = materialize_appdef (example_test_complex_fn , app_args , defaults )
314
314
self .assert_apps (expected_app , actual_app )
315
315
316
316
def test_varargs (self ) -> None :
317
317
materialize_appdef (
318
- _test_var_args ,
318
+ example_var_args ,
319
319
[
320
320
"--foo" ,
321
321
"fooval" ,
@@ -329,15 +329,15 @@ def test_varargs(self) -> None:
329
329
330
330
def test_bool_true (self ) -> None :
331
331
app_def = materialize_appdef (
332
- test_fn_with_bool ,
332
+ example_fn_with_bool ,
333
333
[
334
334
"--flag" ,
335
335
"True" ,
336
336
],
337
337
)
338
338
self .assertEqual ("trainer-with-flag" , app_def .roles [0 ].name )
339
339
app_def = materialize_appdef (
340
- test_fn_with_bool ,
340
+ example_fn_with_bool ,
341
341
[
342
342
"--flag" ,
343
343
"true" ,
@@ -347,15 +347,15 @@ def test_bool_true(self) -> None:
347
347
348
348
def test_bool_false (self ) -> None :
349
349
app_def = materialize_appdef (
350
- test_fn_with_bool ,
350
+ example_fn_with_bool ,
351
351
[
352
352
"--flag" ,
353
353
"False" ,
354
354
],
355
355
)
356
356
self .assertEqual ("trainer-without-flag" , app_def .roles [0 ].name )
357
357
app_def = materialize_appdef (
358
- test_fn_with_bool ,
358
+ example_fn_with_bool ,
359
359
[
360
360
"--flag" ,
361
361
"false" ,
@@ -365,14 +365,14 @@ def test_bool_false(self) -> None:
365
365
366
366
def test_bool_none (self ) -> None :
367
367
app_def = materialize_appdef (
368
- test_fn_with_bool_optional ,
368
+ example_fn_with_bool_optional ,
369
369
[],
370
370
)
371
371
self .assertEqual ("trainer-without-flag" , app_def .roles [0 ].name )
372
372
373
373
def test_varargs_only_flag_first (self ) -> None :
374
374
materialize_appdef (
375
- _test_var_args_first ,
375
+ example_var_args_first ,
376
376
[
377
377
"--" ,
378
378
"--foo" ,
@@ -389,7 +389,7 @@ def test_varargs_only_flag_first(self) -> None:
389
389
390
390
def test_varargs_only_arg_first (self ) -> None :
391
391
materialize_appdef (
392
- _test_var_args_first ,
392
+ example_var_args_first ,
393
393
[
394
394
"fooval" ,
395
395
"--foo" ,
@@ -405,7 +405,7 @@ def test_varargs_only_arg_first(self) -> None:
405
405
406
406
def test_single_letter (self ) -> None :
407
407
materialize_appdef (
408
- _test_single_letter ,
408
+ example_single_letter ,
409
409
[
410
410
"-c" ,
411
411
"arg1" ,
@@ -417,7 +417,7 @@ def test_single_letter(self) -> None:
417
417
)
418
418
419
419
materialize_appdef (
420
- _test_single_letter ,
420
+ example_single_letter ,
421
421
[
422
422
"--c" ,
423
423
"arg2" ,
@@ -439,7 +439,7 @@ def _get_argument_help(
439
439
return None
440
440
441
441
def test_argparster_complex_fn_partial (self ) -> None :
442
- parser = _create_args_parser (_test_complex_fn )
442
+ parser = _create_args_parser (example_test_complex_fn )
443
443
self .assertTupleEqual (
444
444
("AppDef name" , None ),
445
445
none_throws (self ._get_argument_help (parser , "app_name" )),
@@ -469,10 +469,10 @@ def test_argparster_complex_fn_partial(self) -> None:
469
469
)
470
470
471
471
def test_argparser_remainder_main_args (self ) -> None :
472
- parser = _create_args_parser (_test_complex_fn )
472
+ parser = _create_args_parser (example_test_complex_fn )
473
473
474
474
materialize_appdef (
475
- _test_var_args ,
475
+ example_var_args ,
476
476
[
477
477
"--foo" ,
478
478
"fooval" ,
@@ -486,7 +486,7 @@ def test_argparser_remainder_main_args(self) -> None:
486
486
self .assertEqual (_TEST_VAR_ARGS , ("fooval" , ("arg1" , "arg2" ), "barval" ))
487
487
488
488
materialize_appdef (
489
- _test_var_args ,
489
+ example_var_args ,
490
490
[
491
491
"--foo" ,
492
492
"fooval" ,
0 commit comments