Skip to content

Commit f14a80f

Browse files
committed
#1226 Fix failed tests.
1 parent b738105 commit f14a80f

10 files changed

+113
-66
lines changed

apysc/_color/colorless.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ def __init__(self) -> None:
1616
The constant class for the colorlessness.
1717
"""
1818

19-
suffix: str = self._get_attr_or_variable_name_suffix(
20-
value_identifier="colorless"
21-
)
22-
super(Colorless, self).__init__(value="", variable_name_suffix=suffix)
19+
super(Colorless, self).__init__(value="", variable_name_suffix="colorless")
2320

2421

2522
COLORLESS: Final[Colorless] = Colorless()

apysc/_testing/testing_helper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ def apply_test_settings(
170170
"""
171171
from apysc._display.stage import Stage
172172

173+
#
174+
retrying_max_attempts_num = 0
175+
#
173176
if retrying_sleep_seconds is None:
174177
retrying_sleep_seconds = randint(10, 3000) / 1000
175178
_validate_retrying_sleep_seconds(retrying_sleep_seconds=retrying_sleep_seconds)

apysc/_type/false.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ def __init__(self) -> None:
2525
- True_ and False_ constants
2626
- https://simon-ritchie.github.io/apysc/en/true_and_false.html
2727
"""
28-
suffix: str = self._get_attr_or_variable_name_suffix(value_identifier="false")
2928

30-
super(_False, self).__init__(value=False, variable_name_suffix=suffix)
29+
super(_False, self).__init__(value=False, variable_name_suffix="false")

apysc/_type/true.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ def __init__(self) -> None:
2525
- True_ and False_ constants
2626
- https://simon-ritchie.github.io/apysc/en/true_and_false.html
2727
"""
28-
suffix: str = self._get_attr_or_variable_name_suffix(value_identifier="true")
2928

30-
super(_True, self).__init__(value=True, variable_name_suffix=suffix)
29+
super(_True, self).__init__(value=True, variable_name_suffix="true")

tests/_display/test_append_line_cap_attr_expression_mixin.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,46 @@
88
from tests._display.test_graphics_expression import (
99
assert_stroke_linecap_attr_expression_exists,
1010
)
11+
from apysc._type.variable_name_mixin import VariableNameMixIn
12+
from apysc._type.variable_name_suffix_attr_or_var_mixin import (
13+
VariableNameSuffixAttrOrVarMixIn,
14+
)
15+
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
1116

1217

13-
class _TestMixIn(AppendLineCapAttrExpressionMixIn, LineCapMixIn):
18+
class _TestObject(
19+
AppendLineCapAttrExpressionMixIn,
20+
LineCapMixIn,
21+
VariableNameMixIn,
22+
VariableNameSuffixMixIn,
23+
VariableNameSuffixAttrOrVarMixIn,
24+
):
1425
pass
1526

1627

1728
class TestAppendLineCapAttrExpressionMixIn:
1829
@apply_test_settings()
1930
def test__append_line_cap_attr_expression(self) -> None:
20-
mixin_1: AppendLineCapAttrExpressionMixIn = AppendLineCapAttrExpressionMixIn()
31+
instance_1: AppendLineCapAttrExpressionMixIn = AppendLineCapAttrExpressionMixIn()
2132
assert_raises(
2233
expected_error_class=TypeError,
23-
callable_=mixin_1._append_line_cap_attr_expression,
34+
callable_=instance_1._append_line_cap_attr_expression,
2435
match="This instance is not a ",
2536
expression=".attr({\n",
2637
indent_num=2,
2738
skip_appending=False,
2839
)
2940

30-
mixin_2: _TestMixIn = _TestMixIn()
31-
mixin_2.line_cap = ap.LineCaps.ROUND
32-
expression: str = mixin_2._append_line_cap_attr_expression(
41+
instance_2: _TestObject = _TestObject()
42+
instance_2.line_cap = ap.LineCaps.ROUND
43+
expression: str = instance_2._append_line_cap_attr_expression(
3344
expression=".attr({\n",
3445
indent_num=2,
3546
skip_appending=True,
3647
)
3748
assert expression == ".attr({\n"
3849

39-
expression = mixin_2._append_line_cap_attr_expression(
50+
expression = instance_2._append_line_cap_attr_expression(
4051
expression=".attr({\n",
4152
indent_num=2,
4253
skip_appending=False,

tests/_display/test_append_line_joints_attr_expression_mixin.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,47 @@
88
from tests._display.test_graphics_expression import (
99
assert_stroke_linejoin_attr_expression_exists,
1010
)
11+
from apysc._type.variable_name_mixin import VariableNameMixIn
12+
from apysc._type.variable_name_suffix_attr_or_var_mixin import (
13+
VariableNameSuffixAttrOrVarMixIn,
14+
)
15+
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
1116

1217

13-
class _TestMixIn(AppendLineJointsAttrExpressionMixIn, LineJointsMixIn):
18+
class _TestObject(
19+
AppendLineJointsAttrExpressionMixIn,
20+
LineJointsMixIn,
21+
VariableNameMixIn,
22+
VariableNameSuffixMixIn,
23+
VariableNameSuffixAttrOrVarMixIn,
24+
):
1425
pass
1526

1627

1728
class TestAppendLineJointsAttrExpressionMixIn:
1829
@apply_test_settings()
1930
def test__append_line_joints_attr_expression(self) -> None:
20-
mixin_1: AppendLineJointsAttrExpressionMixIn
21-
mixin_1 = AppendLineJointsAttrExpressionMixIn()
31+
instance_1: AppendLineJointsAttrExpressionMixIn
32+
instance_1 = AppendLineJointsAttrExpressionMixIn()
2233
assert_raises(
2334
expected_error_class=TypeError,
24-
callable_=mixin_1._append_line_joints_attr_expression,
35+
callable_=instance_1._append_line_joints_attr_expression,
2536
match="This instance is not a ",
2637
expression=".attr({\n",
2738
indent_num=2,
2839
skip_appending=False,
2940
)
3041

31-
mixin_2: _TestMixIn = _TestMixIn()
32-
mixin_2.line_joints = ap.LineJoints.ROUND
33-
expression: str = mixin_2._append_line_joints_attr_expression(
42+
instance_2: _TestObject = _TestObject()
43+
instance_2.line_joints = ap.LineJoints.ROUND
44+
expression: str = instance_2._append_line_joints_attr_expression(
3445
expression=".attr({\n",
3546
indent_num=2,
3647
skip_appending=True,
3748
)
3849
assert expression == ".attr({\n"
3950

40-
expression = mixin_2._append_line_joints_attr_expression(
51+
expression = instance_2._append_line_joints_attr_expression(
4152
expression=".attr({\n",
4253
indent_num=2,
4354
skip_appending=False,

tests/_display/test_flip_x_mixin.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
from apysc._display.flip_x_mixin import FlipXMixIn
33
from apysc._expression import expression_data_util
44
from apysc._testing.testing_helper import apply_test_settings
5+
from apysc._type.variable_name_mixin import VariableNameMixIn
6+
from apysc._type.variable_name_suffix_attr_or_var_mixin import (
7+
VariableNameSuffixAttrOrVarMixIn,
8+
)
9+
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
510

611

7-
class _TestMixIn(FlipXMixIn):
12+
class _TestObject(
13+
FlipXMixIn,
14+
VariableNameMixIn,
15+
VariableNameSuffixMixIn,
16+
VariableNameSuffixAttrOrVarMixIn,
17+
):
818
def __init__(self) -> None:
919
"""
1020
The class for the testing of the FlipXMixIn class.
@@ -15,7 +25,7 @@ def __init__(self) -> None:
1525
class TestFlipXMixIn:
1626
@apply_test_settings()
1727
def test__initialize_flip_x_if_not_initialized(self) -> None:
18-
interface: _TestMixIn = _TestMixIn()
28+
interface: _TestObject = _TestObject()
1929
interface._initialize_flip_x_if_not_initialized()
2030
assert not interface._flip_x
2131

@@ -25,15 +35,15 @@ def test__initialize_flip_x_if_not_initialized(self) -> None:
2535

2636
@apply_test_settings()
2737
def test_flip_x(self) -> None:
28-
interface: _TestMixIn = _TestMixIn()
38+
interface: _TestObject = _TestObject()
2939
assert not interface.flip_x
3040

3141
interface.flip_x = ap.Boolean(True)
3242
assert interface.flip_x
3343

3444
@apply_test_settings()
3545
def test__append_flip_x_update_expression(self) -> None:
36-
interface: _TestMixIn = _TestMixIn()
46+
interface: _TestObject = _TestObject()
3747
flip_x_1: ap.Boolean = ap.Boolean(True)
3848
flip_x_2: ap.Boolean = ap.Boolean(False)
3949
interface.flip_x = flip_x_1
@@ -52,7 +62,7 @@ def test__append_flip_x_update_expression(self) -> None:
5262

5363
@apply_test_settings()
5464
def test__make_snapshot(self) -> None:
55-
interface: _TestMixIn = _TestMixIn()
65+
interface: _TestObject = _TestObject()
5666
interface.flip_x = ap.Boolean(True)
5767
snapshot_name: str = interface._get_next_snapshot_name()
5868
interface._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
@@ -66,7 +76,7 @@ def test__make_snapshot(self) -> None:
6676

6777
@apply_test_settings()
6878
def test__revert(self) -> None:
69-
interface: _TestMixIn = _TestMixIn()
79+
interface: _TestObject = _TestObject()
7080
interface.flip_x = ap.Boolean(True)
7181
snapshot_name: str = interface._get_next_snapshot_name()
7282
interface._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
@@ -80,6 +90,6 @@ def test__revert(self) -> None:
8090

8191
@apply_test_settings()
8292
def test__append_flip_x_attr_linking_setting(self) -> None:
83-
interface: _TestMixIn = _TestMixIn()
93+
interface: _TestObject = _TestObject()
8494
interface._initialize_flip_x_if_not_initialized()
8595
assert interface._attr_linking_stack["flip_x"] == [ap.Boolean(False)]

tests/_display/test_flip_y_mixin.py

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
from apysc._display.flip_y_mixin import FlipYMixIn
33
from apysc._expression import expression_data_util
44
from apysc._testing.testing_helper import apply_test_settings
5+
from apysc._type.variable_name_mixin import VariableNameMixIn
6+
from apysc._type.variable_name_suffix_attr_or_var_mixin import (
7+
VariableNameSuffixAttrOrVarMixIn,
8+
)
9+
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
510

611

7-
class _TestInterface(FlipYMixIn):
12+
class _TestObject(
13+
FlipYMixIn,
14+
VariableNameMixIn,
15+
VariableNameSuffixMixIn,
16+
VariableNameSuffixAttrOrVarMixIn,
17+
):
818
def __init__(self) -> None:
919
"""
1020
The class for the testing of the FlipYMixIn.
@@ -15,59 +25,59 @@ def __init__(self) -> None:
1525
class TestFlipYMixIn:
1626
@apply_test_settings()
1727
def test__initialize_flip_y_if_not_initialized(self) -> None:
18-
interface: _TestInterface = _TestInterface()
19-
interface._initialize_flip_y_if_not_initialized()
20-
assert not interface._flip_y
28+
instance: _TestObject = _TestObject()
29+
instance._initialize_flip_y_if_not_initialized()
30+
assert not instance._flip_y
2131

22-
interface._flip_y._value = True
23-
interface._initialize_flip_y_if_not_initialized()
24-
assert interface._flip_y
32+
instance._flip_y._value = True
33+
instance._initialize_flip_y_if_not_initialized()
34+
assert instance._flip_y
2535

2636
@apply_test_settings()
2737
def test_flip_y(self) -> None:
28-
interface: _TestInterface = _TestInterface()
29-
assert not interface.flip_y
38+
instance: _TestObject = _TestObject()
39+
assert not instance.flip_y
3040

31-
interface.flip_y = ap.Boolean(True)
32-
assert interface.flip_y
41+
instance.flip_y = ap.Boolean(True)
42+
assert instance.flip_y
3343

3444
@apply_test_settings()
3545
def test__append_flip_y_update_expression(self) -> None:
36-
interface: _TestInterface = _TestInterface()
37-
interface.flip_y = ap.Boolean(True)
46+
instance: _TestObject = _TestObject()
47+
instance.flip_y = ap.Boolean(True)
3848
expression: str = expression_data_util.get_current_expression()
3949
assert '.flip("y");' in expression
4050

4151
@apply_test_settings()
4252
def test__make_snapshot(self) -> None:
43-
interface: _TestInterface = _TestInterface()
44-
interface.flip_y = ap.Boolean(True)
45-
snapshot_name: str = interface._get_next_snapshot_name()
46-
interface._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
47-
if interface._flip_y_snapshots is None:
53+
instance: _TestObject = _TestObject()
54+
instance.flip_y = ap.Boolean(True)
55+
snapshot_name: str = instance._get_next_snapshot_name()
56+
instance._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
57+
if instance._flip_y_snapshots is None:
4858
raise AssertionError()
49-
assert interface._flip_y_snapshots[snapshot_name]
59+
assert instance._flip_y_snapshots[snapshot_name]
5060

51-
interface.flip_y = ap.Boolean(False)
52-
interface._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
53-
assert interface._flip_y_snapshots[snapshot_name]
61+
instance.flip_y = ap.Boolean(False)
62+
instance._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
63+
assert instance._flip_y_snapshots[snapshot_name]
5464

5565
@apply_test_settings()
5666
def test__revert(self) -> None:
57-
interface: _TestInterface = _TestInterface()
58-
interface.flip_y = ap.Boolean(True)
59-
snapshot_name: str = interface._get_next_snapshot_name()
60-
interface._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
61-
interface.flip_y = ap.Boolean(False)
62-
interface._run_all_revert_methods(snapshot_name=snapshot_name)
63-
assert interface.flip_y
67+
instance: _TestObject = _TestObject()
68+
instance.flip_y = ap.Boolean(True)
69+
snapshot_name: str = instance._get_next_snapshot_name()
70+
instance._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
71+
instance.flip_y = ap.Boolean(False)
72+
instance._run_all_revert_methods(snapshot_name=snapshot_name)
73+
assert instance.flip_y
6474

65-
interface.flip_y = ap.Boolean(False)
66-
interface._run_all_revert_methods(snapshot_name=snapshot_name)
67-
assert not interface.flip_y
75+
instance.flip_y = ap.Boolean(False)
76+
instance._run_all_revert_methods(snapshot_name=snapshot_name)
77+
assert not instance.flip_y
6878

6979
@apply_test_settings()
7080
def test__append_flip_y_attr_linking_setting(self) -> None:
71-
interface: _TestInterface = _TestInterface()
72-
interface._initialize_flip_y_if_not_initialized()
73-
assert interface._attr_linking_stack["flip_y"] == [ap.Boolean(False)]
81+
instance: _TestObject = _TestObject()
82+
instance._initialize_flip_y_if_not_initialized()
83+
assert instance._attr_linking_stack["flip_y"] == [ap.Boolean(False)]

tests/_display/test_svg_foreign_object_initialize_width_mixin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
from apysc._display.width_mixin import WidthMixIn
55
from apysc._testing.testing_helper import apply_test_settings
66
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
7+
from apysc._type.variable_name_mixin import VariableNameMixIn
8+
from apysc._type.variable_name_suffix_attr_or_var_mixin import (
9+
VariableNameSuffixAttrOrVarMixIn,
10+
)
11+
from apysc._type.variable_name_suffix_mixin import VariableNameSuffixMixIn
712

813

914
class _TestObject(
1015
WidthMixIn,
16+
VariableNameMixIn,
1117
VariableNameSuffixMixIn,
18+
VariableNameSuffixAttrOrVarMixIn,
1219
SvgForeignObjectInitializeWidthMixIn,
1320
):
1421
def __init__(self) -> None:

tests/_geom/test_path_data_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test__get_svg_char(self) -> None:
2525
svg_char: ap.String = path_data._get_svg_char()
2626
assert svg_char == "M"
2727
assert isinstance(svg_char, ap.String)
28-
assert svg_char._variable_name_suffix == "test_path_data"
28+
assert svg_char._variable_name_suffix == "test_path_data__svg_char"
2929
expression: str = expression_data_util.get_current_expression()
3030
assert "if (" in expression
3131
assert "else {" in expression

0 commit comments

Comments
 (0)