Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail with Python < 3.5 #1

Closed
sbraz opened this issue Dec 26, 2015 · 3 comments
Closed

Tests fail with Python < 3.5 #1

sbraz opened this issue Dec 26, 2015 · 3 comments

Comments

@sbraz
Copy link
Contributor

sbraz commented Dec 26, 2015

Hi Jason,
I just ran the tests with various Python versions and some fail, mostly those related to exceptions because the messages changed throughout versions
For instance, Python 3.4 will yield ValueError: need more than 0 values to unpack whereas 3.5 will have ValueError: too many values to unpack (expected 1)

I don't really know if you can fix this only through doctests but I thought it was worth opening an issue for.

@jaraco jaraco closed this as completed in a86ba7f Dec 26, 2015
@sbraz
Copy link
Contributor Author

sbraz commented Dec 26, 2015

Sorry, I should have mentioned, when I wrote mostly, that there are also two errors with Python 2: one due to the prefix b' and another because range isn't an iterable.

================================================================================== FAILURES ===================================================================================
_________________________________________________________________ [doctest] jaraco.itertools.always_iterable __________________________________________________________________
819     already iterable, return a tuple containing only the item. If item is
820     None, an empty iterable is returned.
821 
822     >>> always_iterable([1,2,3])
823     [1, 2, 3]
824     >>> always_iterable('foo')
825     ('foo',)
826     >>> always_iterable(None)
827     ()
828     >>> always_iterable(range(10))
Expected:
    range(0, 10)
Got:
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

/root/git/jaraco.itertools/jaraco/itertools.py:828: DocTestFailure
_____________________________________________________________________ [doctest] jaraco.itertools.flatten ______________________________________________________________________
456     True
457 
458     Note this will normally ignore string types as iterables.
459 
460     >>> flatten(['ab', 'c'])
461     ['ab', 'c']
462 
463     Same for bytes
464 
465     >>> flatten([b'ab', b'c'])
Expected:
    [b'ab', b'c']
Got:
    ['ab', 'c']

/root/git/jaraco.itertools/jaraco/itertools.py:465: DocTestFailure
===================================================================== 2 failed, 29 passed in 0.08 seconds =====================================================================

@jaraco
Copy link
Owner

jaraco commented Dec 26, 2015

Indeed. I see those as well - they now show up in the travis-run tests.

I found that I could update the always_iterable test to pass on all platforms with this:

@@ -826,7 +828,9 @@
    >>> always_iterable(None)
    ()
-   >>> always_iterable(range(10))
-   range(0, 10)
+
+   >>> print(repr(always_iterable(range(10))).lstrip('x'))
+   range(...10)
+
    >>> def _test_func(): yield "I'm iterable"
    >>> print(next(always_iterable(_test_func())))
    I'm iterable

But that violates the primary purpose of providing clear documentation. I note that I also discovered that it's not possible to include ellipses at the beginning of the expected output because it's interpreted as continuation syntax for the previous line's >>>. I don't think it will be possible to cleanly update that test to pass on 2.7, so I'd like to skip it, but I'm not sure how to do that. I'll see what I can do.

@jaraco
Copy link
Owner

jaraco commented Dec 26, 2015

Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants