Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Install it:
pip install displayhooks
```

Then use it:
Then use:

```python
import sys
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'displayhooks'
version = '0.0.6'
version = '0.0.7'
authors = [
{ name='Evgeniy Blinov', email='zheni-b@yandex.ru' },
]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_autorestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def test_restore():
"""Restore the pre-call sys.displayhook after a decorated function changes it and returns normally."""
hook_before_declaration = sys.displayhook

@autorestore_displayhook
Expand All @@ -22,6 +23,7 @@ def do_something():


def test_restore_after_exception():
"""Restore the pre-call sys.displayhook and propagate an exception from a decorated function that changes it."""
hook_before_declaration = sys.displayhook

@autorestore_displayhook
Expand Down
5 changes: 5 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
@autorestore_displayhook
def test_empty_convert(value):
"""Identity converters preserve normal displayhook output for non-None values."""
@converted_displayhook
def new_displayhook(value: Any) -> Any:
return value
Expand All @@ -34,6 +35,7 @@ def new_displayhook(value: Any) -> Any:

@autorestore_displayhook
def test_empty_convert_with_none():
"""An identity converter preserves sys.displayhook's no-output behavior for None."""
@converted_displayhook
def new_displayhook(value: Any) -> Any:
return value
Expand All @@ -58,6 +60,7 @@ def new_displayhook(value: Any) -> Any:
)
@autorestore_displayhook
def test_elliminating_convertion(value):
"""Suppress output for non-None values when the converter returns None."""
@converted_displayhook
def new_displayhook(value: Any) -> Any: # noqa: ARG001
return None
Expand All @@ -73,6 +76,7 @@ def new_displayhook(value: Any) -> Any: # noqa: ARG001

@autorestore_displayhook
def test_elliminating_convertion_with_none():
"""Write no output when the input is None and the converter returns None."""
@converted_displayhook
def new_displayhook(value: Any) -> Any: # noqa: ARG001
return None
Expand All @@ -97,6 +101,7 @@ def new_displayhook(value: Any) -> Any: # noqa: ARG001
)
@autorestore_displayhook
def test_real_convertion(value):
"""A converted displayhook shows the converter result with normal displayhook formatting."""
@converted_displayhook
def new_displayhook(value: Any) -> Any: # noqa: ARG001
return 'cheburek'
Expand Down
2 changes: 2 additions & 0 deletions tests/test_not_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

@autorestore_displayhook
def test_not_display_only_ints():
"""Suppress integer displayhook output while preserving normal string output."""
not_display(int)

def display_something(something):
Expand All @@ -33,6 +34,7 @@ def display_something(something):
)
@autorestore_displayhook
def test_not_display_ints_and_floats(some_callable):
"""Suppress ints and floats for combined or separate registrations in either order while preserving string output."""
some_callable()

def display_something(something):
Expand Down
Loading