FreeCAD/FreeCAD

Spreadsheet: python tests with lots of asserts are not helpful

Open

#18.439 geöffnet am 12. Dez. 2024

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (5.550 Forks)batch import
Good first issueMod: SpreadsheetMod: TestType: Feature

Repository-Metriken

Stars
 (30.913 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 24T 7h) (217 gemergte PRs in 30 T)

Beschreibung

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

Lost a lot of time today.

src/Mod/Spreadsheet/TestSpreadsheet.py has two tests that contain approx 100 asserts (!!). When any one of those asserts fails, the rest of the asserts in that test are not run so you don't get a picture of whats going on.

After refactoring into some separate classes I broke up some tests to tests of one assert and was finally able to zero in on the real problem. Two not immediately obviously related tests (sqrt, and atan) were failing. Turns out both call sqrt, which is erroring out (why is TBA) and returns a string instead of a quantity which crashes assertMostlyEqual.

It really is terribly important to strive for one assert per test!

Summary:

  1. Tests should be fixed to single asserts
  2. Errors should be detected

Full version info

OS: macOS Sequoia (15.1)
Architecture: arm64
Version: 1.1.0dev.39470 (Git)
Build type: Release
Branch: units
Hash: 618e4222ed5ce955d12df172f3e36dd5a60d0d54
Python 3.12.7, Qt 6.7.3, Coin 4.0.3, Vtk , OCC 7.8.1
Locale: English/Australia (en_AU)
Stylesheet/Theme/QtStyle: FreeCAD Dark.qss/FreeCAD Dark/

Subproject(s) affected?

None

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Contributor Guide