diff --git a/toolz/compatibility.py b/toolz/compatibility.py index 9a1242c1..28bef91d 100644 --- a/toolz/compatibility.py +++ b/toolz/compatibility.py @@ -3,7 +3,7 @@ "needed in Python 3 and has been deprecated. Please " "import these utilities directly from the standard library. " "This module will be removed in a future release.", - category=DeprecationWarning) + category=DeprecationWarning, stacklevel=2) import operator import sys diff --git a/toolz/functoolz.py b/toolz/functoolz.py index c568aae8..067a3d49 100644 --- a/toolz/functoolz.py +++ b/toolz/functoolz.py @@ -5,9 +5,12 @@ from importlib import import_module from textwrap import dedent from types import MethodType +import sys from .utils import no_default +PYPY = hasattr(sys, 'pypy_version_info') and sys.version_info[0] > 2 + __all__ = ('identity', 'apply', 'thread_first', 'thread_last', 'memoize', 'compose', 'compose_left', 'pipe', 'complement', 'juxt', 'do', diff --git a/toolz/tests/test_compatibility.py b/toolz/tests/test_compatibility.py index db304027..ec87cf3b 100644 --- a/toolz/tests/test_compatibility.py +++ b/toolz/tests/test_compatibility.py @@ -1 +1,10 @@ -import toolz.compatibility \ No newline at end of file + +import pytest +import importlib + +def test_compat_warn(): + with pytest.warns(DeprecationWarning): + # something else is importing this, + import toolz.compatibility + # reload to be sure we warn + importlib.reload(toolz.compatibility) diff --git a/toolz/tests/test_itertoolz.py b/toolz/tests/test_itertoolz.py index 61618725..25e7d39a 100644 --- a/toolz/tests/test_itertoolz.py +++ b/toolz/tests/test_itertoolz.py @@ -542,8 +542,8 @@ def test_random_sample(): assert rsample1 != rsample2 - assert mk_rsample(object) == mk_rsample(object) - assert mk_rsample(object) != mk_rsample(object()) + assert mk_rsample(hash(object)) == mk_rsample(hash(object)) + assert mk_rsample(hash(object)) != mk_rsample(hash(object())) assert mk_rsample(b"a") == mk_rsample(u"a") assert raises(TypeError, lambda: mk_rsample([])) diff --git a/versioneer.py b/versioneer.py index 64fea1c8..8daee9f0 100644 --- a/versioneer.py +++ b/versioneer.py @@ -339,9 +339,9 @@ def get_config_from_root(root): # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") - parser = configparser.SafeConfigParser() - with open(setup_cfg, "r") as f: - parser.readfp(f) + parser = configparser.ConfigParser() + + parser.read(setup_cfg) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name):