Skip to content

Commit

Permalink
Merge pull request #13 from eriknw/travis_simple
Browse files Browse the repository at this point in the history
Add basic .travis.yml
  • Loading branch information
eriknw committed Apr 17, 2014
2 parents cafa3e7 + 2a76e62 commit 79e01b8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 90 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"

before_install:
- pip install git+https://github.com/pytoolz/toolz.git
- pip install cython

install:
- python setup.py build_ext --inplace

# commands to run tests
script:
- nosetests --with-doctest cytoolz

notifications:
email: false
77 changes: 0 additions & 77 deletions cydoctest.py

This file was deleted.

13 changes: 6 additions & 7 deletions cytoolz/tests/test_doctests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cytoolz.utils import testmod
from cytoolz.utils import module_doctest

import cytoolz
import cytoolz.dicttoolz
Expand All @@ -7,10 +7,9 @@
import cytoolz.recipes


# This currently doesn't work. Use `cydoctest.py` instead.
def test_doctest():
testmod(cytoolz)
testmod(cytoolz.dicttoolz)
testmod(cytoolz.functoolz)
testmod(cytoolz.itertoolz)
testmod(cytoolz.recipes)
assert module_doctest(cytoolz) is True
assert module_doctest(cytoolz.dicttoolz) is True
assert module_doctest(cytoolz.functoolz) is True
assert module_doctest(cytoolz.itertoolz) is True
assert module_doctest(cytoolz.recipes) is True
12 changes: 9 additions & 3 deletions cytoolz/tests/test_none_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ def test_itertoolz():
assert raises(TypeError, lambda: last(None))
tested.append('last')

assert list(mapcat(None, [[1], [2]])) == [[1], [2]]
# XXX
assert (raises(TypeError, lambda: list(mapcat(None, [[1], [2]]))) or
list(mapcat(None, [[1], [2]])) == [[1], [2]])
assert raises(TypeError, lambda: list(mapcat(identity, [None, [2]])))
assert raises(TypeError, lambda: list(mapcat(identity, None)))
tested.append('mapcat')
Expand Down Expand Up @@ -265,11 +267,15 @@ def test_itertoolz():

def test_recipes():
tested = []
assert countby(None, [1, 2]) == {(1,): 1, (2,): 1}
# XXX
assert (raises(TypeError, lambda: countby(None, [1, 2])) or
countby(None, [1, 2]) == {(1,): 1, (2,): 1})
assert raises(TypeError, lambda: countby(identity, None))
tested.append('countby')

assert list(partitionby(None, [1, 2])) == [(1,), (2,)]
# XXX
assert (raises(TypeError, lambda: list(partitionby(None, [1, 2]))) or
list(partitionby(None, [1, 2])) == [(1,), (2,)])
assert raises(TypeError, lambda: list(partitionby(identity, None)))
tested.append('partitionby')

Expand Down
8 changes: 5 additions & 3 deletions cytoolz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def fix_module_doctest(module):
module.__test__[name] = value.__doc__


def testmod(m=None, *args, **kwargs):
def module_doctest(m, *args, **kwargs):
"""
Fix a Cython module's doctests, then call doctest.testmod()
All other arguments are passed directly to doctest.testmod().
Return True on success, False on failure.
"""
# fix_module_doctest(m) # XXX this doesn't work when using `nosetest`
doctest.testmod(m, *args, **kwargs)
fix_module_doctest(m)
return doctest.testmod(m, *args, **kwargs).failed == 0

0 comments on commit 79e01b8

Please sign in to comment.