Repository: pytest-dev/pytest-faulthandler (language: python)

Issue:
Please release dummy 2.0 package
Hi,

I think it would be cool if you could release a 2.0 package that is just a dummy package that simply depends on pytest>5.0.

This would help downstream transition to pytest 5.0 without explicitly depending on it.

Thanks!

Mark

https://github.com/scikit-image/scikit-image/issues/3986


Discussion / hints:
Hi @hmaarrfk,

I was thinking of doing that, but wasn't sure if it would help or not. But I guess it indeed it would be helpful. I will look into it. 👍 

 
Cool awesome!

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index faabf37..cdf47f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,23 +1,11 @@
 language: python
 dist: xenial
-python:
-  - '2.7'
-  - '3.4'
-  - '3.5'
-  - '3.6'
-  - '3.7'
-  - 'pypy'
-  - 'pypy3'
-  - '3.8-dev'
-install:
-  - pip install --upgrade pip
-  - pip install tox-travis
-script:
-  - tox
+
+install: skip
+
+script: skip
 
 stages:
-- name: test
-  if: repo = pytest-dev/pytest-faulthandler AND tag IS NOT present
 - name: deploy
   if: repo = pytest-dev/pytest-faulthandler AND tag IS present
 
@@ -34,11 +22,11 @@ jobs:
       deploy:
         provider: pypi
         user: nicoddemus
-        distributions: sdist bdist_wheel  
+        distributions: sdist bdist_wheel
         skip_upload_docs: true
         password:
           secure: QK8ibmCJZeyO9Homs0BljGKNXVQFicw9YhOBozofYZRxexVjUqCGr78BfXPvLcBuAnHcM0XCuzQOMaBIS1T5gi5jiF/hZXxtLfIdzZoxxBTyHyVV6quhzjXJsWC9ILT3GXmhhGiY/eJLCJbPn//uFeEAPYxKST2ANBoxieAfuko=
         on:
           tags: true
           repo: pytest-dev/pytest-faulthandler
-  
+
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 5407724..f603116 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,15 @@
+2.0.1
+-----
+
+* This release is a dummy package requiring pytest 5.0: this plugin has
+  been integrated into pytest 5.0, so this plugin should no longer
+  be required (`#36`_).
+
+  Maintenance also has been moved to pytest core.
+
+.. _#36: https://github.com/pytest-dev/pytest-faulthandler/issues/36
+
+
 1.6.0
 -----
 
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..1aba38f
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,1 @@
+include LICENSE
diff --git a/README.rst b/README.rst
index 6cb513f..e2e6426 100644
--- a/README.rst
+++ b/README.rst
@@ -2,10 +2,6 @@
 pytest-faulthandler
 ===================
 
-.. note::
-
-    This plugin is now part of pytest core since pytest 5.0, so users should not install 
-    this plugin together with that pytest version.
 
 Plugin for pytest that automatically enables the
 `faulthandler <https://faulthandler.readthedocs.io/>`_ module during tests.
@@ -13,22 +9,9 @@ Plugin for pytest that automatically enables the
 Inspired by the
 `nose faulthandler <https://github.com/schlamar/nose-faulthandler>`_ plugin.
 
-|python| |version| |anaconda| |ci| |appveyor| 
-
-.. |version| image:: http://img.shields.io/pypi/v/pytest-faulthandler.png
-  :target: https://pypi.python.org/pypi/pytest-faulthandler
+**This plugin is now part of pytest core since pytest 5.0, so users should not install this plugin together with that pytest version.**
 
-.. |ci| image:: https://api.travis-ci.org/pytest-dev/pytest-faulthandler.svg?branch=master
-  :target: https://travis-ci.org/pytest-dev/pytest-faulthandler
-
-.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/faf052p56ipp1i4u/branch/master?svg=true
-  :target: https://ci.appveyor.com/project/pytestbot/pytest-faulthandler
-  
-.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-faulthandler.svg
-    :target: https://pypi.python.org/pypi/pytest-faulthandler
-    
-.. |anaconda| image:: https://anaconda.org/conda-forge/pytest-faulthandler/badges/version.svg
-    :target: https://anaconda.org/conda-forge/pytest-faulthandler
+**Version 2.0.0 of this package is a dummy package for pytest 5.0 compatibility**.
 
 
 Usage
@@ -57,7 +40,7 @@ Install
 Install using `pip <http://pip-installer.org/>`_:
 
 .. code-block:: console
-    
+
     $ pip install pytest-faulthandler
 
 Change Log
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 163754c..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-install:
-  - C:\Python36\python -m pip install --upgrade pip
-  - C:\Python36\python -m pip install --upgrade tox virtualenv
-
-build: false  # Not a C# project
-
-test_script:
-  - C:\Python36\scripts\tox --skip-missing-interpreters
-
-skip_tags: true
diff --git a/setup.py b/setup.py
index 05e2282..2a0b9a1 100644
--- a/setup.py
+++ b/setup.py
@@ -6,36 +6,21 @@
 
 setup(
     name='pytest-faulthandler',
-    use_scm_version=True,
-    py_modules=['pytest_faulthandler'],
+    version="2.0.1",
     url='https://github.com/pytest-dev/pytest-faulthandler',
     license='MIT',
-    install_requires=['pytest>=4.0,<5.0'],
-    test_requires=['pytest-mock>=0.6'],
-    setup_requires=['setuptools_scm'],
+    install_requires=['pytest>=5.0'],
     author='Bruno Oliveira',
     author_email='nicoddemus@gmail.com',
-    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
-    description='py.test plugin that activates the fault handler module for tests',
+    description='py.test plugin that activates the fault handler module for tests (dummy package)',
     long_description=long_description,
-    extras_require={
-        ':python_version=="2.7" and platform_python_implementation != "PyPy"': ['faulthandler'],
-    },
-    entry_points={
-        'pytest11': ['pytest_faulthandler = pytest_faulthandler'],
-    },
     keywords='pytest faulthandler',
     classifiers=[
-        'Development Status :: 5 - Production/Stable',
+        'Development Status :: 6 - Mature',
         'Framework :: Pytest',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
         'Operating System :: OS Independent',
-        'Programming Language :: Python :: 2.7',
-        'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.4',
-        'Programming Language :: Python :: 3.5',
-        'Programming Language :: Python :: 3.6',
         'Topic :: Software Development :: Testing',
     ]
 )
diff --git a/tox.ini b/tox.ini
deleted file mode 100644
index 1f8f7de..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-[tox]
-envlist = py{27,34,35,36,37},pypy,pypy3
-
-[testenv]
-commands = py.test test_pytest_faulthandler.py
-passenv=USER USERNAME
-deps=pytest-mock>=0.6
-
-[pytest]
-addopts = -p pytester --runpytest=subprocess


Test patch:
diff --git a/pytest_faulthandler.py b/pytest_faulthandler.py
deleted file mode 100644
index c0a0cef..0000000
--- a/pytest_faulthandler.py
+++ /dev/null
@@ -1,91 +0,0 @@
-import io
-import os
-import sys
-import warnings
-
-import pytest
-
-
-def pytest_addoption(parser):
-    group = parser.getgroup('terminal reporting')
-    group.addoption(
-        '--no-faulthandler', action='store_false', dest='fault_handler',
-        default=True, help='Disable faulthandler module.')
-    
-    group.addoption(
-        '--faulthandler-timeout', type=int, dest='fault_handler_timeout',
-        metavar='TIMEOUT', default=0,
-        help='Dump the traceback of all threads if a test takes '
-             'more than TIMEOUT seconds to finish.\n'
-             'Not available on Windows.')
-
-
-def pytest_configure(config):
-    if config.getoption('fault_handler'):
-        import faulthandler
-        try:
-            stderr_fileno = sys.stderr.fileno()
-        except (AttributeError, io.UnsupportedOperation):
-            # python-xdist monkeypatches sys.stderr with an object that is not an actual file.
-            # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
-            # This is potentially dangerous, but the best we can do.
-            stderr_fileno = sys.__stderr__.fileno()
-        stderr_fd_copy = os.dup(stderr_fileno)
-        config.fault_handler_stderr = os.fdopen(stderr_fd_copy, 'w')
-        faulthandler.enable(config.fault_handler_stderr)
-        # we never disable faulthandler after it was enabled, see #3
-
-
-def pytest_report_header(config):
-    if config.getoption('fault_handler_timeout') > 0:
-        if not timeout_support_available():
-            return 'faulthandler: timeout support not available on this platform'
-
-
-def timeout_support_available():
-    """Returns True if the current platform/python support faulthandler
-    timeout.
-    """
-    import faulthandler
-    return hasattr(faulthandler, 'dump_traceback_later') and \
-        hasattr(faulthandler, 'cancel_dump_traceback_later')
-
-
-@pytest.hookimpl(hookwrapper=True)
-def pytest_runtest_protocol(item):
-    enabled = item.config.getoption('fault_handler')
-    timeout = item.config.getoption('fault_handler_timeout')
-    timeout_supported = timeout_support_available()
-    if enabled and timeout > 0 and timeout_supported:
-        import faulthandler
-        stderr = item.config.fault_handler_stderr
-        faulthandler.dump_traceback_later(timeout, file=stderr)
-        try:
-            yield
-        finally:
-            faulthandler.cancel_dump_traceback_later()
-    else:
-        yield
-
-
-def _cancel_traceback_dump():
-    """Cancel traceback dumping if timeout support is available.
-    """
-    if timeout_support_available():
-        import faulthandler
-        faulthandler.cancel_dump_traceback_later()
-
-
-@pytest.hookimpl(tryfirst=True)
-def pytest_enter_pdb():
-    """Cancel any traceback dumping due to timeout before entering pdb.
-    """
-    _cancel_traceback_dump()
-
-
-@pytest.hookimpl(tryfirst=True)
-def pytest_exception_interact():
-    """Cancel any traceback dumping due to an interactive exception being
-    raised.
-    """
-    _cancel_traceback_dump()
diff --git a/test_pytest_faulthandler.py b/test_pytest_faulthandler.py
deleted file mode 100644
index 214a8df..0000000
--- a/test_pytest_faulthandler.py
+++ /dev/null
@@ -1,118 +0,0 @@
-import pytest
-import sys
-from pytest_faulthandler import timeout_support_available
-
-pytest_plugins = ['pytester']
-
-
-def test_enabled(testdir):
-    """Test single crashing test displays a traceback."""
-    testdir.makepyfile('''
-    import faulthandler
-    def test_crash():
-        faulthandler._sigabrt()
-    ''')
-    result = testdir.runpytest()
-    result.stderr.fnmatch_lines([
-        "*Fatal Python error*"
-    ])
-    assert result.ret != 0
-
-
-def test_crash_near_exit(testdir):
-    """Test that fault handler displays crashes that happen even after
-    pytest is exiting (for example, when the interpreter is shutting down).
-    """
-    testdir.makepyfile('''
-    import faulthandler
-    import atexit
-    def test_ok():
-        atexit.register(faulthandler._sigabrt)
-    ''')
-    result = testdir.runpytest()
-    result.stderr.fnmatch_lines([
-        "*Fatal Python error*"
-    ])
-    assert result.ret != 0
-
-
-def test_disabled(testdir):
-    """Test option to disable fault handler in the command line.
-    """
-    testdir.makepyfile('''
-    import faulthandler
-    def test_disabled():
-        assert not faulthandler.is_enabled()
-    ''')
-    result = testdir.runpytest('--no-faulthandler')
-    result.stdout.fnmatch_lines([
-        "*1 passed*"
-    ])
-    assert result.ret == 0
-
-
-@pytest.mark.parametrize('enabled', [True, False])
-@pytest.mark.skipif(not timeout_support_available(), reason='no timeout support')
-def test_timeout(testdir, enabled):
-    """Test option to dump tracebacks after a certain timeout (linux only).
-    If faulthandler is disabled, no traceback will be dumped.
-    """
-    testdir.makepyfile('''    
-    import time
-    def test_timeout():
-        time.sleep(2.0)
-    ''')
-    args = ['--faulthandler-timeout=1']
-    if not enabled:
-        args.append('--no-faulthandler')
-        
-    result = testdir.runpytest(*args)
-    tb_output = 'most recent call first'
-    if sys.version_info[:2] == (3, 3):
-        tb_output = 'Thread'
-    if enabled:
-        result.stderr.fnmatch_lines([
-            "*%s*" % tb_output,
-        ])
-    else:
-        assert tb_output not in result.stderr.str()
-    result.stdout.fnmatch_lines([        
-        "*1 passed*",
-    ])
-    assert result.ret == 0
-
-
-@pytest.mark.skipif(timeout_support_available(), reason='timeout available')
-def test_timeout_not_available(testdir):
-    """Test that --faulthandler-timeout option on shows a warning on
-    platforms that don't support it (#8).
-    """
-    testdir.makepyfile('''
-        def test_dummy():
-            pass
-    ''')
-    result = testdir.runpytest('--faulthandler-timeout=5', '-rw')
-    result.stdout.fnmatch_lines([
-        "faulthandler: timeout support not available on this platform",
-    ])
-    assert result.ret == 0
-
-
-@pytest.mark.skipif(not timeout_support_available(), reason='no timeout support')
-@pytest.mark.parametrize('hook_name', ['pytest_enter_pdb',
-                                       'pytest_exception_interact'])
-def test_cancel_timeout_on_hook(mocker, pytestconfig, hook_name):
-    """Make sure that we are cancelling any scheduled traceback dumping due
-    to timeout before entering pdb (#12) or any other interactive
-    exception (#14).
-    """
-    import faulthandler
-    import pytest_faulthandler
-
-    m = mocker.spy(faulthandler, 'cancel_dump_traceback_later')
-
-    # call our hook explicitly, we can trust that pytest will call the hook
-    # for us at the appropriate moment
-    hook_func = getattr(pytest_faulthandler, hook_name)
-    hook_func()
-    assert m.call_count == 1