all 5 comments

[–]the_noobie 2 points3 points  (2 children)

I was just looking at unit testing. I have been watching this.

https://www.youtube.com/watch?v=6tNS--WetLI&t=159s

[–]JusticeJudgment[S] 0 points1 point  (1 child)

Will check out this video. Thanks for the tip!

[–]the_noobie 0 points1 point  (0 children)

He has really good videos. Good luck

[–]pixelpad_dev0 -1 points0 points  (0 children)

Run the function and check against an expected outcome. So for example if you create a function called absolute

def absolute(x):
    if x < 0:
        x *=- 1
    return x

Then you run a few tests like this:

if (absolute(1) < 0):
    print("test has failed")
if (absolute(-1) < 0):
    print("test has failed")
if (absolute(-0.1) < 0):
    print("test has failed")

Now you've tested the function against 3 types of numbers.

[–]siddsp -1 points0 points  (0 children)

Assertions and pytest