Session Ready
Exercise

Use a fixture for a clean data file

In the video, you saw how the preprocess() function creates a clean data file.

The get_data_as_numpy_array() function takes the path to this clean data file as the first argument and the number of columns of data as the second argument. It returns a NumPy array holding the data.

In a previous exercise, you wrote the test test_on_clean_file() without using a fixture. That's bad practice! This time, you'll use the fixture clean_data_file(), which

  • creates a clean data file in the setup,
  • yields the path to the clean data file,
  • removes the clean data file in the teardown.

The contents of the clean data file that you will use for testing is printed in the IPython console.

pytest, os, numpy as np and get_data_as_numpy_array() have been imported for you.

Instructions
100 XP
  • Add the correct decorator that would turn clean_data_file() into a fixture.
  • Pass an argument to the test test_on_clean_file() so that it uses the fixture.
  • Pass the clean data file path yielded by the fixture as the first argument to the function get_data_as_numpy_array().