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