Created
December 8, 2015 05:47
-
-
Save manuphatak/d3e36133aeba95e46390 to your computer and use it in GitHub Desktop.
Dealing with `atexit` and setup.py test command deleting modules.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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