>You’re flip flopping all over the place with your descriptions of tests.
The straw man of my argument living in your head flip flopped. I did no such thing.
When I said "basic tests" I meant demonstrate the behavior under normal circumstances". If you're doing TDD on 60% of your code base you'll write enough of these.
>Negative tests are, amongst other things, checking that your functions behave correctly when you put garbage in.
This is a completely unsuitable use case for a test. If your function expects non-garbage it should raise an exception if it gets garbage with a sanity check.
I have no problems with exception per se but what you’ve now done is push your error checking into the runtime which means your application could crash at unexpected times. This might be fine for your typical use cases but it is a terrible way to go about building software if you’re writing headless services.
The point of functional tests is they catch developer errors before your codebase hits production. Which you cannot guarantee if your error checking is only in the runtime.
Disclaimer: I write services used by millions of people (literally) each day. Some of those services are written in Python.
> In theory but in theory any application could crash at an unexpected time
That’s a terribly unsatisfactory answer.
> In my experience on a half decent code base these sanity checks never trigger during production in normal code; they're designed to get triggered during tests. They're there to make it easy to track down the root cause of bugs.
There are a lot of conditionals attached to your statement. ;)
> The times when they did get triggered on production code I did it intentionally as a way to debug a train-wreck of an application in production.
If you hadnt relied on type checking in your runtime then you might not have needed to get to the stage where you were debugging something in production.
> I've been doing this for 10 years - on many projects that have had millions of users. You're not special.
I didn’t say I was special. I was just making a point that I have used Python on important services just in case I was coming off as a Python hater.
Btw ive Been doing this for 30 years - though most of that hasn’t been in Python but most of the last 20 years has been high availability systems. Which may explain why I’m less willing to push buggy code to production and rely on exceptions than you.
This comment crosses into personal attack, which is not allowed here. If you'd please review https://news.ycombinator.com/newsguidelines.html and follow the rules when posting to HN, we'd be grateful.
Weird how you've come to that conclusion when I've been the one talking about testing and you keep shrugging it off with "well I prefer exceptions" because "sometimes you have to debug things on production".
I honestly don't think you know the first thing about writing stable software so are now just lashing out at me.
This also crosses into personal attack, which is also not ok here. If you would also please review https://news.ycombinator.com/newsguidelines.html and follow the rules when posting to HN, we'd also be grateful.
Basically (and this goes for both of you as well as the rest of us), when you find yourself unable to keep from replying as irritation mounts, it's best to wrest oneself away from the internet for a bit.
The straw man of my argument living in your head flip flopped. I did no such thing.
When I said "basic tests" I meant demonstrate the behavior under normal circumstances". If you're doing TDD on 60% of your code base you'll write enough of these.
>Negative tests are, amongst other things, checking that your functions behave correctly when you put garbage in.
This is a completely unsuitable use case for a test. If your function expects non-garbage it should raise an exception if it gets garbage with a sanity check.
I wrote one just a few hours ago like so: