|
11 | 11 | """ |
12 | 12 | Что нужно проверить: |
13 | 13 |
|
14 | | -2. При попытке вызвать без тильды суперфункцию, в которой есть return или raise, должно подниматься исключение, причем . |
15 | 14 | 3. Трейсбек исключения из п. 2 информативен (т.е. содержит конкретную строчку кода, и короткий). Но есть возможность увидеть полный "настоящий" трейсбек. |
16 | 15 | 4. Базовые кейсы работают в глобальном скоупе. |
17 | | -6. С синтаксисом ~ нормально поднимаются исключения. |
18 | 16 |
|
19 | 17 | Что проверено: |
20 | 18 |
|
21 | 19 | 1. Все базово работает без аргументов и с аргументами, для обычных, асинк и генераторных функций. |
22 | 20 | 5. С использованием синтаксиса ~ для вызова обычных функций можно возвращать значения, с аргументами и без. |
| 21 | +2. При попытке вызвать без тильды суперфункцию, в которой есть return или raise, должно подниматься исключение. |
| 22 | +6. С синтаксисом ~ нормально поднимаются исключения. |
23 | 23 | """ |
24 | 24 |
|
25 | 25 |
|
@@ -382,28 +382,60 @@ def test_there_are_no_exceptions_if_not_tilde_mode_and_in_function_is_empty_retu |
382 | 382 | def function(): |
383 | 383 | with async_context: |
384 | 384 | return |
385 | | - pass |
386 | 385 |
|
387 | 386 |
|
388 | 387 | def test_there_are_no_exceptions_if_not_tilde_mode_and_in_function_is_return_true_in_async_block(): |
389 | 388 | @superfunction(tilde_syntax=False) |
390 | 389 | def function(): |
391 | 390 | with async_context: |
392 | 391 | return True |
393 | | - pass |
394 | 392 |
|
395 | 393 |
|
396 | 394 | def test_there_are_no_exceptions_if_not_tilde_mode_and_in_function_is_empty_return_in_generator_block(): |
397 | 395 | @superfunction(tilde_syntax=False) |
398 | 396 | def function(): |
399 | 397 | with generator_context: |
400 | 398 | return |
401 | | - pass |
402 | 399 |
|
403 | 400 |
|
404 | 401 | def test_there_are_no_exceptions_if_not_tilde_mode_and_in_function_is_return_true_in_generator_block(): |
405 | 402 | @superfunction(tilde_syntax=False) |
406 | 403 | def function(): |
407 | 404 | with generator_context: |
408 | 405 | return True |
409 | | - pass |
| 406 | + |
| 407 | + |
| 408 | +def test_async_function_with_all_content_in_generator_context(): |
| 409 | + @superfunction |
| 410 | + def function(): |
| 411 | + with generator_context: |
| 412 | + return True |
| 413 | + |
| 414 | + assert run(function()) is None |
| 415 | + |
| 416 | + |
| 417 | +def test_async_function_with_all_content_in_sync_context(): |
| 418 | + @superfunction |
| 419 | + def function(): |
| 420 | + with sync_context: |
| 421 | + return True |
| 422 | + |
| 423 | + assert run(function()) is None |
| 424 | + |
| 425 | + |
| 426 | +def test_usual_tilde_function_with_all_content_in_generator_context(): |
| 427 | + @superfunction |
| 428 | + def function(): |
| 429 | + with generator_context: |
| 430 | + return True |
| 431 | + |
| 432 | + assert ~function() is None |
| 433 | + |
| 434 | + |
| 435 | +def test_usual_tilde_function_with_all_content_in_async_context(): |
| 436 | + @superfunction |
| 437 | + def function(): |
| 438 | + with async_context: |
| 439 | + return True |
| 440 | + |
| 441 | + assert ~function() is None |
0 commit comments