designing a app to be as testable as posible. When writing a application that you like to, write unit tests the best options it to always on everything written for a application to not be dependent on that the application is running. Since if we can import a function and muck or just test the isolated function. One example on this is a database function, and a database. In this example i will use sqlite3 as a example. sqlite have a option to start the db in memory. This is something is very useful since you like to have a clean state of the database for every test.
Continuing with a example. In the test setup function a in memory sqlite db is created and data is imported that is needed to test some database functions. On teardown the db is closed and on the next test its recreated to have every test start in a clean state and not be dependent the order of a test.
Looking on two example tests that is then importing a db function to add and remove rows in the inactive table. between the tests the db is recreated which makes the test start from a known state which makes it’s easier to recreate and control the what is tested.
The full application that is used as a example can be found here. Source