Python assert

Hi all, I am trying to use some existing Python code in Mojo. I couldn't find an alternative for the "assert" statements I use for testing the code. What's the best solution for this?
6 Replies
Shubham Ugare
Shubham UgareOP12mo ago
I tried this, but I think it only works in debug mode. debug_assert(2==3, "error") is ignored when I run the code in standard mode
OSIX
OSIX12mo ago
in that case you could implement your on assert_equal function and return https://docs.modular.com/mojo/stdlib/builtin/error.html
OSIX
OSIX12mo ago
Python documentation
unittest — Unit testing framework
Source code: Lib/unittest/init.py(If you are already familiar with the basic concepts of testing, you might want to skip to the list of assert methods.) The unittest unit testing framework was ...
OSIX
OSIX12mo ago
^this last lib exports a TestCase object which has methods like assertEqual, assertTrue... etc
Shubham Ugare
Shubham UgareOP12mo ago
ok, I'll try this. Thanks!
Want results from more Discord servers?
Add your server