From the course: AI-Powered Development: GitHub Copilot in Visual Studio Code

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Inspect generated code

Inspect generated code

Every test framework has its own conventions and PyTest is no different. For PyTest, that starts with naming. Test files typically begin with test underscore so that's what you see up here test underscore payment underscore data and within that file the individual tests also start with test underscore so PyTest can discover and run them. Here are some of the test cases Copilot generated and you can see that Copilot is following those naming conventions correctly by creating multiple focused test functions. Let's start by looking at this first one on line six. Here's the word test underscore, then the name of the function that is testing, and then the scenario. Weekday results in a weekday. The code is proposing a starting date, putting that in a variable, then calling my function, passing in the proposed date, storing that as a result, calculating the future date and then asserting that they match. Now here's another scenario where the date lands on Saturday and what I really…

Contents