From the course: Secure Coding in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Run the test, fix the code

Solution: Run the test, fix the code - Python Tutorial

From the course: Secure Coding in Python

Start my 1-month free trial

Solution: Run the test, fix the code

(upbeat music) - [Instructor] So why is our test failing? So let's head over to 04_05, feed, post serializers.py. And if you look at line 11, you'll see that someone has decided to add ID to the list of fields in the post serializer. Now in this case, that someone is yours truly. We should expect developers to change things and we cannot expect everyone to always know why decisions were made. So this is something that is going to happen, and it's our jobs as developers to make sure we put in place mechanisms that pick up on these mistakes. So the way to fix this would be to remove ID from the list of fields. And I'm going to head back to my terminal. Here I am at 04, 04_05, so I'll cd into feed, clear my terminal one more time and run pipenv run pytest. And the tests pass now. Now, suppose this test did not exist. How are we to pick up on this regression? This kind of thing can go undetected for a very long time,…

Contents