diff --git a/android/src/toga_android/widgets/button.py b/android/src/toga_android/widgets/button.py index 2c1a1a1840..ab9bfab545 100644 --- a/android/src/toga_android/widgets/button.py +++ b/android/src/toga_android/widgets/button.py @@ -28,15 +28,14 @@ def get_text(self): return str(self.native.getText()) def set_text(self, text): - self.native.setText(self.interface.text) + self.native.setText(text) def set_enabled(self, value): self.native.setEnabled(value) def set_font(self, font): - if font: - self.native.setTextSize(TypedValue.COMPLEX_UNIT_SP, font._impl.get_size()) - self.native.setTypeface(font._impl.get_typeface(), font._impl.get_style()) + self.native.setTextSize(TypedValue.COMPLEX_UNIT_SP, font._impl.get_size()) + self.native.setTypeface(font._impl.get_typeface(), font._impl.get_style()) def set_on_press(self, handler): # No special handling required diff --git a/testbed/tests/assertions.py b/testbed/tests/assertions.py index fea793626c..10e3335cd3 100644 --- a/testbed/tests/assertions.py +++ b/testbed/tests/assertions.py @@ -7,9 +7,15 @@ # * assert_set_get(obj, name, pytest.approx(value)) - for floating point values # * assert_set_get(obj, name, set_value, get_value) - where the two values are different def assert_set_get(obj, name, value): - """Calls a setter, then asserts that the same value is returned by the getter.""" + """Calls a setter, then asserts that the same value is returned by the getter. + + :param obj: The object to inspect + :param name: The name of the attribute to set and get + :param value: The value to set + """ setattr(obj, name, value) - assert getattr(obj, name) == value + actual = getattr(obj, name) + assert actual == value, f"Expected {value!r}, got {actual!r}" def assert_color(actual, expected):