Skip to content

Commit

Permalink
Increment version to v2.1.0 and add Python2.x deprecation warning (#458)
Browse files Browse the repository at this point in the history
* Increment version and add Python2.x deprecation warning

Change test to actually test no warnings when on python3

flake8 compliant

* fix development status classifier
  • Loading branch information
neozenith authored Aug 8, 2019
1 parent 1b565d3 commit 78e21aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run_tests(self):

setup(
name='vcrpy',
version='2.0.1',
version='2.1.0',
description=(
"Automatically mock your HTTP interactions to simplify and "
"speed up testing"
Expand All @@ -52,7 +52,7 @@ def run_tests(self):
license='MIT',
tests_require=['pytest', 'mock', 'pytest-httpbin'],
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Programming Language :: Python',
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_vcr_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys


def test_vcr_import_deprecation(recwarn):

if 'vcr' in sys.modules:
# Remove imported module entry if already loaded in another test
del sys.modules['vcr']

import vcr # noqa: F401

if sys.version_info[0] == 2:
assert len(recwarn) == 1
assert issubclass(recwarn[0].category, DeprecationWarning)
else:
assert len(recwarn) == 0
7 changes: 7 additions & 0 deletions vcr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import warnings
import sys
from .config import VCR

# Set default logging handler to avoid "No handler found" warnings.
Expand All @@ -9,6 +11,11 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass

if sys.version_info[0] == 2:
warnings.warn(
"Python 2.x support of vcrpy is deprecated and will be removed in an upcoming major release.",
DeprecationWarning
)

logging.getLogger(__name__).addHandler(NullHandler())

Expand Down

0 comments on commit 78e21aa

Please sign in to comment.