Python for Decision Makers and Business Leaders Transcripts
Chapter: Testing
Lecture: Testing in Python

Login or purchase this course to watch this video and the rest of the course contents.
0:00 How do you know your software is working the way you expect it? How do you know that new bugs were not introduced? Or that, when you find them
0:07 they don't get reintroduced somewhere along the way? Well, you right test for your code. Maybe you've seen a graph that looks like this.
0:15 The general idea is that it is much cheaper to find bugs and correct them early in the lifecycle. When you're planning it, creating architecture
0:23 maybe when you're writing the code you found a bug and you fixed it before you ever release it. Those are relatively cheap.
0:29 We do, maybe in some organizations, have QA Quality Assurance steps, where we find bugs there. Not all companies have those, but some do.
0:37 Once you've released the software depending on how you release it it can be a lot more expensive. If you need to go and do a deployment to the website
0:46 that's not necessarily huge but if it's affected customers; if somebody's messed up a credit card purchase and then you've got to go back and deal with
0:54 all that in the different systems and you've got to do the customer support or a package was sent to the wrong place
0:59 or a buy decision was made on stocks when it should have been sell those all of the sudden have huge implications.
1:05 And, of course, if you're shipping desktop software well, it's just a pain to get that sent out again. So the idea is that
1:12 testing lowers the overall cost of software systems and that you should definitely do it. Good news is, Python has two solid options
1:20 more than that actually but two of them are really, really good. It has a built-in testing framework that just comes with it.
1:26 Remember standard library, and the batteries included? Well one of those batteries is a testing battery. You can go and test your code like that.
1:34 But most professional software these days uses this thing called Pytest. And Pytest is extremely simple. You can see on the screen
1:40 that first gray box shows the entirety of a program and it being tested. It turns out it's incredibly simple but it also is very extensible
1:50 and does a lot of cool things. So we're going to talk just very briefly for a few minutes about testing code with Python. We're not going to write code
1:58 we're not going to spend too much time on this but I just do want to address it a little bit because it is important in languages like Python.
2:04 Also, you can use Python to test other things. Python is simple to write tests in maybe you can test other devices, or languages, or so on.
2:12 We'll touch on that, too.

Talk Python's Mastodon Michael Kennedy's Mastodon