diff --git a/.travis.yml b/.travis.yml index 8bd09fb..e87ea64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,5 @@ python: - "nightly" before_install: pip install flake8 before_script: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics -script: nosetests -e fuzz +install: pip install pytest +script: pytest -k "not fuzz" diff --git a/IPy.py b/IPy.py index b80e6a3..7cdc012 100644 --- a/IPy.py +++ b/IPy.py @@ -9,8 +9,11 @@ __version__ = '1.00' import bisect -import collections import types +try: + import collections.abc as collections_abc +except ImportError: + import collections as collections_abc # Definition of the Ranges for IPv4 IPs # this should include www.iana.org/assignments/ipv4-address-space @@ -1022,10 +1025,10 @@ def v46map(self): raise ValueError("%s cannot be converted to an IPv4 address." % repr(self)) -class IPSet(collections.MutableSet): +class IPSet(collections_abc.MutableSet): def __init__(self, iterable=[]): # Make sure it's iterable, otherwise wrap - if not isinstance(iterable, collections.Iterable): + if not isinstance(iterable, collections_abc.Iterable): raise TypeError("'%s' object is not iterable" % type(iterable).__name__) # Make sure we only accept IP objects @@ -1099,7 +1102,7 @@ def len(self): def add(self, value): # Make sure it's iterable, otherwise wrap - if not isinstance(value, collections.Iterable): + if not isinstance(value, collections_abc.Iterable): value = [value] # Check type @@ -1113,7 +1116,7 @@ def add(self, value): def discard(self, value): # Make sure it's iterable, otherwise wrap - if not isinstance(value, collections.Iterable): + if not isinstance(value, collections_abc.Iterable): value = [value] # This is much faster than iterating over the addresses diff --git a/test/test_IPy.py b/test/test_IPy.py index dc4b61f..8dbbd97 100644 --- a/test/test_IPy.py +++ b/test/test_IPy.py @@ -788,7 +788,11 @@ def run(self): it.setDaemon(True) it.start() it.join(timeout_duration) - if it.isAlive(): + if hasattr(it, 'is_alive'): + is_alive = it.is_alive() + else: + is_alive = it.isAlive() + if is_alive: return default else: return it.result