From the course: Testing Python Data Science Code

Unlock this course with a free trial

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

Solution: Test with pytest

Solution: Test with pytest - Python Tutorial

From the course: Testing Python Data Science Code

Solution: Test with pytest

(upbeat music) - Let's take a look at my solution. One of the first problems is how to find this file. It can vary, depending on the idea that you're using and where you're running the test from. What I'm usually doing is using path. And then I'm saying that the current directory, which I traditionally called here is using the under file variable which holds the current filing. I'm getting the absolute path to it. And then the parent which means here's holds the absolute path to the directory containing tests, splitter. And now when I'm writing a function through low split cases I'm saying the case file is here and split cases do. And now I open the file use the YAML safe load to load the data. And then I iterate over every test case in the data and yielding the size, the chunk size and the chunks and the reason I'm doing that and not returning the test cases or the data is because I don't want to couple the testing…

Contents