1
1
from __future__ import annotations
2
2
3
+ import logging
3
4
import warnings
4
5
from contextlib import contextmanager
5
6
from typing import TYPE_CHECKING , Generator , cast
@@ -358,7 +359,7 @@ def test_secret_masks_text(self) -> None:
358
359
e = Enter .the_secret (text )
359
360
360
361
assert e .text == text
361
- assert e .text_to_log == "[CENSORED]"
362
+ assert e .text_to_log == "' [CENSORED]' "
362
363
363
364
def test_text_to_log_humanizes_keys (self ) -> None :
364
365
"""unicode key values are turned into human-readable text"""
@@ -431,11 +432,16 @@ def test_exception(self, Tester: Actor) -> None:
431
432
432
433
def test_describe (self ) -> None :
433
434
assert (
434
- Enter ("blah" ).into (TARGET ).describe () == f' Enter " blah" into the { TARGET } .'
435
+ Enter ("blah" ).into (TARGET ).describe () == f" Enter ' blah' into the { TARGET } ."
435
436
)
436
437
assert (
437
438
Enter .the_secret ("blah" ).into (TARGET ).describe ()
438
- == f'Enter "[CENSORED]" into the { TARGET } .'
439
+ == f"Enter '[CENSORED]' into the { TARGET } ."
440
+ )
441
+
442
+ assert (
443
+ Enter ("\ue008 \ue004 \ue007 " ).into (TARGET ).describe ()
444
+ == f"Enter 'SHIFT TAB ENTER' into the { TARGET } ."
439
445
)
440
446
441
447
def test_subclass (self ) -> None :
@@ -447,6 +453,32 @@ def new_method(self) -> bool:
447
453
448
454
assert SubEnter .the_text ("blah" ).new_method () is True
449
455
456
+ def test_beat_logging (
457
+ self , Tester : Actor , caplog : pytest .LogCaptureFixture
458
+ ) -> None :
459
+ target , element = get_mocked_target_and_element ()
460
+ text = 'Speak "Friend" and Enter'
461
+ caplog .set_level (logging .INFO )
462
+ Enter .the_text (text ).into_the (target ).perform_as (Tester )
463
+
464
+ assert [r .msg for r in caplog .records ] == [
465
+ f"Tester enters 'Speak \" Friend\" and Enter' into the { target } ."
466
+ ]
467
+
468
+ def test_beat_logging_chain (
469
+ self , Tester : Actor , caplog : pytest .LogCaptureFixture
470
+ ) -> None :
471
+ chain = get_mocked_chain ()
472
+ target , element = get_mocked_target_and_element ()
473
+ text = "Hello, Champion City."
474
+
475
+ caplog .set_level (logging .INFO )
476
+ Enter .the_text (text ).into_the (target ).add_to_chain (Tester , chain )
477
+
478
+ assert [r .msg for r in caplog .records ] == [
479
+ f" Enter 'Hello, Champion City.' into the { target } !"
480
+ ]
481
+
450
482
def test_positional_arg_warns (self ) -> None :
451
483
with pytest .warns (DeprecationWarning ):
452
484
Enter ("" , True )
0 commit comments