Why would they? Assert not null probably takes an Object as a parameter and, if Iām not mistaken, literally any value/type can be coerced into Object
public void testFindLatestCompletedCaseRevision()
{
int result =
this.caseHistorizationDao.findLatestCompletedCaseRevision(CASE_NUMBER);
Assert.assertNotNull(result);
}
If you run python with the -O flag assert statements are ignored, otherwise it will raise an AssertionError if the condition is false. It's supposed to just be used during development so I guess I've been abusing it for years.
assert(cond), 'Cond was False'
is the same as
if __debug__: # not -O
if not cond:
raise AssertionError('Cond was false')
25
u/[deleted] Feb 23 '23
??? this is basically 1 function call and then checking for null, where is the bad code??
3
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 23 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/Cootshk Feb 24 '23
Bad question: what does assert do? (Python)
1
u/QueenVogonBee Feb 24 '23
The programmer is being assertive.
-21
u/Shawn11564 Feb 23 '23
OP has never written tests before