Closed guidorice closed 5 months ago
In mojo v24.3 there are some very useful sounding enhancements
debug_assert() now prints its location (filename, line, and column where it was called) in its error message. Similarly, the assert helpers in the testing module now include location information in their messages. changelog
Great news, thanks @guidorice!
@franckrasolo If you give it a try, just a tip you will need to manually copy over the latest MojoTest struct from https://github.com/guidorice/mojo-pytest/blob/58512e8ed1a76fa67f49d228d1758dec8be525f2/example/tests/util.mojo Thanks for your interest!
@guidorice Yes, I did exactly that as I'm currently using everything that's in the examples
folder (untracked by Git) and realised that it was a little out of date.
When a python test is collected by pytest, it reports a line number and context like this:
In IDEs like VSCode, we can quickly navigate to the failed test function/class by Cmd-click on the file:line.
In mojo-pytest this would be a useful enhancement at least to have at least the line number. It should be possible to resolve at the line number of failed MojoTestItems by scanning for the test name, and/or the assert failure message, in the mojo source file.