Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Dealing with `atexit` and setup.py test command deleting modules.
from setuptools import setup
from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
import sys
errno = pytest.main(self.test_args)
self.handle_exit()
sys.exit(errno)
@staticmethod
def handle_exit():
import atexit
atexit._run_exitfuncs()
setup(cmdclass={'test': PyTest})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment