#Python Unit Testing

109 messages · Page 1 of 1 (latest)

heavy ridge
#

I am learning Unit testing in python again just to refresh my memory on it, and I am curious if in the real world like in real jobs do we have to do unit tests cuz I feel like it’s a hassle making a unit test then testing a bunch of different possibilities, isn’t it better to just run it and test directly instead

wet gyroBOT
#

Hello! Thank you for your question. To help you best, could you please provide more details? Please include:

  • The specific problem you're encountering.
  • Any code you've written related to the issue.
  • Any error messages you're seeing.
  • What you've already tried to solve the problem.

The more information you provide, the better we can assist you!

#

-# Python @mortal atlas @pale nacelle @heavy ridge

slim ridge
#

Yes, in the real world you're more likely to use unit tests over manually testing stuff

mortal atlas
#

Think of the unit test as an automation. It’s doing the exact steps you would but in an automated fashion.

pale nacelle
heavy ridge
#

Oh ok I get it now that

#

Thx

heavy ridge
#

But I guess it’s better than manually testing

#

Is it just me btw that I use vs code with one x more zoom

pale nacelle
#

tests can be annoying

slim ridge
pale nacelle
#

but in general they are a great thing to have

slim ridge
#

One thing that's nice about having unit tests is that it can notify you when you have regressions in your code

pale nacelle
#

true

#

sadly not always can they be tested, like this that needs fully tested by hand, since it generates random data that you can't really reasonably test

#

also floating point can suck for unit tests, because behavior may vary by platform (even if the changes are rare)

heavy ridge
#

Ooo nice

slim ridge
#

Hmm, I guess it'll depend on what you're asserting tho

pale nacelle
#

normally, yes

#

but because that program for example, generates randomized images, you need a way to quantify that the image is becoming closer to the target, and code may be good at that, but it's a ton easier to just run my own test on 2 images over 10 minutes then compare it myself than it is to go through and make sure the svgs are emitted properly, the files look fine, etc with code

#

in other words, due to how the program works it's just as easy if not easier to self test

heavy ridge
#

So anyone uses 2x zoom on their vs code or is it just me

slim ridge
#

You need to increase everything or just your font size?

#

I see no reason to make everything bigger

pale nacelle
# pale nacelle in other words, due to how the program works it's just as easy if not easier to ...

the generator itself is fully tested just by me looking, xml validity is tested by png output, png output is tested by my manual test, coord issues would cause errors, i cannot reasonably test byte-for-byte since that is not a goal of the project, seed changes are tested by my running 2 manual tests, and round trip is not something i can test either, so running 2 commands manually is really the most efficient way

pale nacelle
#

in fact i think i knocked all my fonts down a point

slim ridge
#

Yeah same

#

Also, bro gave up on neovim smh

heavy ridge
#

Nah I have to use vs code for cs50

pale nacelle
#

especially after swapping my font to one that's way more legible (caskaydia code) it's super easy to read even the tiniest fonts

heavy ridge
#

Really

#

What font u thinks the best ?

slim ridge
#

Cascadia is nice

#

I've switched to monaspace tho

pale nacelle
#

caskaydia + rose pine moon my beloved

heavy ridge
#

I use andromeda

slim ridge
#

Monaspace + catppuccin mocha for me (can't send a pic cause I'm at work)

heavy ridge
#

Yeah I tried catppuchin

#

Isn’t it too pink I think

pale nacelle
#

i used to use mocha but i found rose pine to look a lot nicer for me

heavy ridge
#

But I really like it too

slim ridge
heavy ridge
#

I do I do

pale nacelle
#

colors are hard

heavy ridge
#

You edited it ?

pale nacelle
heavy ridge
#

lol

#

I like the default mocha

pale nacelle
#

i used to

slim ridge
#

Ain't no way

pale nacelle
#

i legitimately used to lightmode

#

hell i still do on my homescreen

heavy ridge
#

I usually do monospace - andromeda - font size 20

#

I like it so that my code is very clear in front of me

pale nacelle
slim ridge
#

Oh my 😳

pale nacelle
#

i am still working on that icon pack

#

well

#

was

#

idk

slim ridge
#

Meanwhile me lol

pale nacelle
#

the tidal one was a test, some day i might get back to it

heavy ridge
#

this my setup lol

pale nacelle
#

now it's like 40 bucks

slim ridge
pale nacelle
#

ooooooof yeah

heavy ridge
#

its for cs50 anyway

pale nacelle
#

api key leaks man, they will kill ya

heavy ridge
#

its just for monitoring bitcoin prices

slim ridge
heavy ridge
#

if u wanna try sure

heavy ridge
#

plus its not the full api key

pale nacelle
#

always be very careful with your api keys

heavy ridge
#

its like half

#

i deleted the other half

pale nacelle
#

even then

#

like

heavy ridge
pale nacelle
#

i won't even let my api keys in bash

#

i have bash history fully disabled so i can swap to bash any time i need to test curl to an api

heavy ridge
#

damn

pale nacelle
#

(normally use zsh)

heavy ridge
#

alr ill take care of them

pale nacelle
#

yeh

#

api key leaks may seem inconsequential now

#

but if you get into the habit of not caring now

heavy ridge
#

which one do u guys think looks better

pale nacelle
#

you're inevitably going to not care later

#

which what

#

what changed

heavy ridge
#

thus one with like 20 font size and the last pic with 14 font size

pale nacelle
#

aside from no api key

#

i mean i can't say i would use the 20

#

i use 14 on 1440p and 10 on my 720p laptop

slim ridge
#

Just do what's comfortable for you man

heavy ridge
#

ok

pale nacelle
#

yeah ultimately looks don't matter as long as you like it