Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichFroebel committed Oct 10, 2024
1 parent 05302d4 commit b98b421
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions brother_ql_web/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def margin_right_scaled(self) -> int:
return self._scale_margin(self.margin_right)

@property
def fill_color(self) -> Tuple[int, int, int]:
def fill_color(self) -> tuple[int, int, int]:
return (255, 0, 0) if "red" in self.label_size else (0, 0, 0)

@property
Expand All @@ -87,7 +87,7 @@ def font_path(self) -> str:
return path

@property
def width_height(self) -> Tuple[int, int]:
def width_height(self) -> tuple[int, int]:
try:
width, height = cast(
tuple[int, int], label_type_specs[self.label_size]["dots_printable"]
Expand Down
14 changes: 8 additions & 6 deletions tests/test_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@ def __init__(self, device_specifier: str) -> None:

# 1) One label.
parameters.label_count = 1
with mock.patch.object(labels.logger, "info") as info_mock, mock.patch.object(
Backend, "write"
) as write_mock:
with (
mock.patch.object(labels.logger, "info") as info_mock,
mock.patch.object(Backend, "write") as write_mock,
):
labels.print_label(
parameters=parameters,
qlr=qlr,
Expand All @@ -339,9 +340,10 @@ def __init__(self, device_specifier: str) -> None:

# 2) Multiple labels.
parameters.label_count = 5
with mock.patch.object(labels.logger, "info") as info_mock, mock.patch.object(
Backend, "write"
) as write_mock:
with (
mock.patch.object(labels.logger, "info") as info_mock,
mock.patch.object(Backend, "write") as write_mock,
):
labels.print_label(
parameters=parameters,
qlr=qlr,
Expand Down
37 changes: 21 additions & 16 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ def test_main(self) -> None:
}
label_sizes = [("62", "62mm labels"), "42", "42mm labels"]

with mock.patch(
"sys.argv",
[
"brother_ql_web/__main__",
"--configuration",
self.example_configuration_path,
],
), mock.patch("logging.basicConfig") as basic_config_mock, mock.patch(
"brother_ql_web.utils.collect_fonts", return_value=fonts
) as fonts_mock, mock.patch(
"brother_ql_web.utils.get_label_sizes", return_value=label_sizes
) as labels_mock, mock.patch(
"brother_ql_web.utils.get_backend_class", return_value=Backend
) as backend_mock, mock.patch(
"brother_ql_web.web.main"
) as main_mock:
with (
mock.patch(
"sys.argv",
[
"brother_ql_web/__main__",
"--configuration",
self.example_configuration_path,
],
),
mock.patch("logging.basicConfig") as basic_config_mock,
mock.patch(
"brother_ql_web.utils.collect_fonts", return_value=fonts
) as fonts_mock,
mock.patch(
"brother_ql_web.utils.get_label_sizes", return_value=label_sizes
) as labels_mock,
mock.patch(
"brother_ql_web.utils.get_backend_class", return_value=Backend
) as backend_mock,
mock.patch("brother_ql_web.web.main") as main_mock,
):
main()

configuration = self.example_configuration
Expand Down

0 comments on commit b98b421

Please sign in to comment.