diff --git a/src/psc/gallery/examples/interest_calculator/calculator.py b/src/psc/gallery/examples/interest_calculator/calculator.py index 9383ffc..f0ddb80 100644 --- a/src/psc/gallery/examples/interest_calculator/calculator.py +++ b/src/psc/gallery/examples/interest_calculator/calculator.py @@ -27,3 +27,6 @@ def setup(): """When Pyodide starts up, enable the Calculate button.""" calculate_button = Element("calc") # noqa calculate_button.element.removeAttribute("disabled") + + +setup() diff --git a/src/psc/gallery/examples/interest_calculator/index.html b/src/psc/gallery/examples/interest_calculator/index.html index c9e8635..7b61460 100644 --- a/src/psc/gallery/examples/interest_calculator/index.html +++ b/src/psc/gallery/examples/interest_calculator/index.html @@ -72,10 +72,7 @@ - - - setup() - + diff --git a/tests/examples/test_interest_calculator.py b/tests/examples/test_interest_calculator.py index 156a401..a5696d2 100644 --- a/tests/examples/test_interest_calculator.py +++ b/tests/examples/test_interest_calculator.py @@ -10,14 +10,14 @@ def test_calculator(fake_document: FakeDocument, fake_element: FakeElement) -> None: """Ensure the loaded interest function works correctly.""" - from psc.gallery.examples.interest_calculator.calculator import interest - fake_document.values["principal"] = "100" fake_document.values["interest_rate"] = "0.1" fake_document.values["time"] = "10" fake_document.values["simple_interest"] = "0.1" fake_document.values["compound_interest"] = "0.1" fake_document.values["calc"] = "Calculate" + from psc.gallery.examples.interest_calculator.calculator import interest + interest() # type: ignore assert fake_document.log[0] == "simple interest: 200" assert fake_document.log[1] == "compound interest: 259"