-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move dict parsing logic to format class
move dict parsing logic to format class inherit Enum from str rename string formatter simplify
- Loading branch information
Showing
9 changed files
with
131 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from __future__ import annotations | ||
|
||
from chispa.formatting.formats import RESET, Color, Format, FormattingConfig, Style | ||
from chispa.formatting.terminal_string_formatter import format_terminal_string | ||
from chispa.formatting.terminal_string_formatter import format_string | ||
|
||
__all__ = ("Style", "Color", "FormattingConfig", "Format", "format_terminal_string", "RESET") | ||
__all__ = ("Style", "Color", "FormattingConfig", "Format", "format_string", "RESET") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
from chispa.formatting import RESET, format_terminal_string | ||
from chispa.formatting import RESET, format_string | ||
from chispa.formatting.formats import Color, Format, Style | ||
|
||
|
||
def test_format_with_enum_inputs(): | ||
format = Format(color=Color.BLUE, style=[Style.BOLD, Style.UNDERLINE]) | ||
formatted_string = format_terminal_string("Hello, World!", format) | ||
expected_string = f"{Style.BOLD.value}{Style.UNDERLINE.value}{Color.BLUE.value}Hello, World!{RESET}" | ||
formatted_string = format_string("Hello, World!", format) | ||
expected_string = f"{Style.BOLD}{Style.UNDERLINE}{Color.BLUE}Hello, World!{RESET}" | ||
assert formatted_string == expected_string | ||
|
||
|
||
def test_format_with_no_style(): | ||
format = Format(color=Color.GREEN, style=[]) | ||
formatted_string = format_terminal_string("Hello, World!", format) | ||
expected_string = f"{Color.GREEN.value}Hello, World!{RESET}" | ||
formatted_string = format_string("Hello, World!", format) | ||
expected_string = f"{Color.GREEN}Hello, World!{RESET}" | ||
assert formatted_string == expected_string | ||
|
||
|
||
def test_format_with_no_color(): | ||
format = Format(color=None, style=[Style.BLINK]) | ||
formatted_string = format_terminal_string("Hello, World!", format) | ||
expected_string = f"{Style.BLINK.value}Hello, World!{RESET}" | ||
formatted_string = format_string("Hello, World!", format) | ||
expected_string = f"{Style.BLINK}Hello, World!{RESET}" | ||
assert formatted_string == expected_string | ||
|
||
|
||
def test_format_with_no_color_or_style(): | ||
format = Format(color=None, style=[]) | ||
formatted_string = format_terminal_string("Hello, World!", format) | ||
formatted_string = format_string("Hello, World!", format) | ||
expected_string = "Hello, World!" | ||
assert formatted_string == expected_string |
File renamed without changes.