Our package has a few example scripts that show how the package can be used.
Whenever we make a breaking change in my package, the examples may need to be updated. Right now I need to manually keep track of this, by checking whether the example scripts still run. Is there some way to add a test_examples function to my unit testing setup that doesn't assert the return value of a specific function, but simply runs all (or specific) files in the examples folder and checks that these scripts complete without error?
This was much easier than I thought it would be. I simply needed to add a test function to my pytest setup that imported the example scripts. Since these scripts aren't protected by a, if __name__ == "__main__": statement, all content is run. If there are errors along the way, the import, and therefore the test, will fail.
Add automatic test to package examples