python-sure/9f0e834b2e5eea5dfe21d5be4ea...

65 lines
1.8 KiB
Diff

From 9f0e834b2e5eea5dfe21d5be4ea6a3df47baf0b9 Mon Sep 17 00:00:00 2001
From: Timo Furrer <timo.furrer@roche.com>
Date: Wed, 20 Feb 2019 13:26:46 +0100
Subject: [PATCH] Import ABCs from collections.abc. Closes #150
---
.travis.yml | 10 +++++++---
sure/compat.py | 5 +++++
sure/old.py | 5 +----
tests/test_assertion_builder.py | 2 +-
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/sure/compat.py b/sure/compat.py
index df8d323..c53ab28 100644
--- a/sure/compat.py
+++ b/sure/compat.py
@@ -5,6 +5,11 @@
import six
from collections import OrderedDict
+try:
+ from collections.abc import Iterable
+except ImportError:
+ from collections import Iterable
+
from sure.terminal import red, green, yellow
diff --git a/sure/old.py b/sure/old.py
index e861b26..53e4ee4 100644
--- a/sure/old.py
+++ b/sure/old.py
@@ -22,10 +22,6 @@
from copy import deepcopy
from pprint import pformat
from functools import wraps
-try:
- from collections import Iterable
-except ImportError:
- Iterable = (list, dict, tuple, set)
try:
import __builtin__ as builtins
@@ -43,6 +39,7 @@
from sure.core import _get_file_name
from sure.core import _get_line_number
from sure.core import itemize_length
+from sure.compat import Iterable
def identify_callable_location(callable_object):
diff --git a/tests/test_assertion_builder.py b/tests/test_assertion_builder.py
index 4dc00fc..c043648 100644
--- a/tests/test_assertion_builder.py
+++ b/tests/test_assertion_builder.py
@@ -137,7 +137,7 @@ def test_should_be_a():
("this(None).should.be.none")
assert this(1).should.be.an(int)
- assert this([]).should.be.a('collections.Iterable')
+ assert this([]).should.be.a('sure.compat.Iterable')
assert this({}).should_not.be.a(list)
def opposite():