Recent Changes · Search:

Dispense


Navigation Tips - Dritte


PmWiki

pmwiki.org

edit SideBar

Tests

< Mujpy.MujpyVsMusrfitChiSquare | Index | Mujpy.Data >


Automated tests

  • Old command driven version test.py, requires copying manually single tests and fit json files from the checkout
  • New GUI version copies the required fit json files and data to local dirs but relies on manual button clicking

Auto tests for the GUI

  • ChatGPT answers (to be followed at a later stage)
    • Yes—and you can automate much of it directly in Python. For the kind of display bug you just found, browser tests add an important second check.
  1. Trigger widget actions from Python
instrument_select.value = 'lem'
confirm_button.click()
fit_button.click()
  • Your ipyw_..._dial helpers can be tested this way too, provided the test can access their selection widgets and confirmation buttons. When creating them, retain references—for example, self.instrument_select — instead of keeping everything in inaccessible local variables.
  • These actions can form repeatable test scenarios: launch GUI → select instrument → load data → select model → fit.
  • Crucially, check the results after each action, rather than merely checking that the script finishes. Widget callbacks can catch exceptions and send them to notebook output, allowing a test to appear successful despite a failure.
  1. Test what actually appears in the browser
    • Python tests can confirm that a figure exists while missing exactly your recent problem: its canvas was never displayed.
    • For that, use Playwright with JupyterLab’s Galata helpers. They can open notebooks, execute cells, interact with controls, inspect visible elements, and capture screenshots. ipywidgets itself uses Galata for visual regression tests. [GitHub](https://github.com/jupyterlab/jupyterlab/blob/main/galata/README.md?utm_source=chatgpt.com)
    • A mujpy browser test could:
  2. Launch mujpy with a small, fixed dataset.
  3. Load a known model and click Fit.
  4. Check that the Log tab contains a visible plot canvas.
  5. Fit again and check that the plot remains visible.
  6. Save a screenshot when a check fails.
    • For animations, it should also check that the displayed plot advances—not merely that a canvas exists. Qt popup windows need separate testing; these browser checks cover ipympl.
    • For mujpy, I would start with four plotting scenarios:
!Scenario!Check
Single plot, first fitCanvas appears beside the log
Single plot, second fitCanvas survives clearing and reuse
Animated plot, first fitCanvas appears and animation advances
Animated plot, second fitAnimation still works after reuse
  • Then add your initialization branches: test mode, PSI with an existing link, and PSI requiring selection. Those tests would also catch the duplicate-GUI problem.
  • The smallest useful next step is one repeatable Python test scenario using .value and .click(). It does not require redesigning the GUI. To make it concrete, we would need the code for one of your dialog helpers and the widgets used to load data, load a model, and start the fit.

< Mujpy.MujpyVsMusrfitChiSquare | Index | Mujpy.Data >

Edit - History - Print - PDF - Recent Changes - Search
Page last modified on October 30, 2026, at 10:10 AM