Use pytest-mocker so you don’t need to run a function in your code during testing.

For example, a function which writes to disk.

def delete_table():
	...
	write_database_to_disk()
 
	return

Use a mocker to skip over this function in the test.

def test_delete_table(mocker):
	mocker.patch(path.to.where.function.is.used.write_database_to_disk)
 
	...

Note, it is important to know where to mock. This must be where the function is called, which is not necessarily where it is defined.

More notes here and here.