# Testing Your Analysis

A number in a report is something people act on, so prove it's right. Write pytest tests for your pandas functions with small tables made by hand, check whole tables at once, and test a chart by what it contains instead of how it looks, then see where your data skills go next.

Updated: November 19, 2026

## [Tests for Analysis Code](https://www.ask-codey.com/courses/python-data-analysis/topics/data-tests-for-analysis)

1. [Your First Tests with pytest](https://www.ask-codey.com/lessons/python-testing-first-tests) (Journeyman): A test is a small function that runs your code on an example and makes sure the answer is right, and pytest finds every test, runs it, and shows exactly what came back when one fails.
2. [Testing pandas Functions with Small Tables](https://www.ask-codey.com/lessons/data-testing-pandas-functions) (Journeyman): A real week of data is too big to check by hand, so a test runs the function on a few rows made by hand, where the right answer is clear, and checks one number, a column or a whole table with assert_frame_equal, then the empty table, the missing value and the table it was given.
3. [Testing a Chart Without Looking at It](https://www.ask-codey.com/lessons/data-testing-charts) (Journeyman): A chart function that returns its Figure and Axes can be tested like any other function, by reading what the Axes holds, its title, axis labels, each bar's height and a line's data, with matplotlib's Agg backend set in conftest.py and every figure closed with plt.close.

## [Exercise: Test the Food Truck Report](https://www.ask-codey.com/courses/python-data-analysis/topics/exercise-data-test-food-truck-report)

1. [Exercise: Test the Food Truck Report](https://www.ask-codey.com/lessons/exercise-data-test-food-truck-report) (Journeyman): Write the pytest tests for the Greenway Food Truck's working report functions, from the total of each sale and the week's numbers to the location table, the saved file and the chart, and prove they're good by catching four bugs the check plants in copies of the code.

## [Where to Go Next](https://www.ask-codey.com/courses/python-data-analysis/topics/data-next-steps)

1. [Where to Go Next](https://www.ask-codey.com/lessons/data-where-to-go-next) (Journeyman): Look back at everything this course taught you, from loading and cleaning data to charts, reports and tests, try a report across every week of the food truck's sales, plan an analysis of your own, and see where your data skills can go next.

Source: https://www.ask-codey.com/courses/python-data-analysis/chapters/data-testing-analysis
