diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-10-31 21:44:34 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-10-31 21:44:34 +0000 |
commit | ed3e3f257126ac07f8f07367a50b3399acd85070 (patch) | |
tree | 5c54b0b8e01d40adf231ed7cd5707d09e752ec72 /test/base/utils.py | |
parent | bba54e320df55d50f55715805498dc3ce8584991 (diff) | |
download | sqlalchemy-ed3e3f257126ac07f8f07367a50b3399acd85070.tar.gz |
- util.flatten_iterator() func doesn't interpret strings with
__iter__() methods as iterators, such as in pypy [ticket:1077].
Diffstat (limited to 'test/base/utils.py')
-rw-r--r-- | test/base/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/base/utils.py b/test/base/utils.py index a28af90ed..c3d026f04 100644 --- a/test/base/utils.py +++ b/test/base/utils.py @@ -92,6 +92,21 @@ class ColumnCollectionTest(TestBase): class ImmutableSubclass(str): pass +class FlattenIteratorTest(TestBase): + def test_flatten(self): + assert list(util.flatten_iterator([[1,2,3], [4,5,6], 7, 8])) == [1,2,3,4,5,6,7,8] + + def test_str_with_iter(self): + """ensure that a str object with an __iter__ method (like in PyPy) is not interpreted + as an iterable. + + """ + class IterString(str): + def __iter__(self): + return iter(self + "") + + assert list(util.flatten_iterator([IterString("asdf"), [IterString("x"), IterString("y")]])) == ["asdf", "x", "y"] + class HashOverride(object): def __init__(self, value=None): self.value = value |