Skip to content

Add Travis CI testing #15

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Test coverage configuration.
# Usage:
# pip install coverage
# coverage erase # clears previous data if any
# coverage run -m unittest2
# coverage html # creates ./htmlcov/*.html (check index.html)
[run]
branch = true
source = extras_mongoengine
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*.pyc
build/
venv/

# Coverage
/htmlcov
/.coverage
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
language: python
python:
- '2.6'
- '2.7'
- '3.2'
- '3.3'
- '3.4'
- pypy
- pypy3
env:
- PYMONGO=2.7
- PYMONGO=2.8
- PYMONGO=3.0
- PYMONGO=dev
matrix:
fast_finish: true
before_install:
# Install MongoDB
- travis_retry sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' |
sudo tee /etc/apt/sources.list.d/mongodb.list
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install mongodb-org-server
install:
# 1. Install Python
- sudo apt-get install python-dev python3-dev
# 2. Install general requirements (Python packages)
- pip install -r requirements.txt
# 3. Enums in Python only became available in 3.4.
# The package `enum34` listed in `requirements-python<3.4.txt` is a backport.
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r 'requirements-python<3.4.txt'; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.2* ]]; then pip install -r 'requirements-python<3.4.txt'; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.3* ]]; then pip install -r 'requirements-python<3.4.txt'; fi
- if [[ $TRAVIS_PYTHON_VERSION == pypy* ]]; then pip install -r 'requirements-python<3.4.txt'; fi
# Coverage 4.0 doesn't support Python 3.2. Install an older version
# before coveralls tries to install the latest. (pypy3 is really Python 3.2)
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then travis_retry pip install 'coverage<4.0'; fi
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy3' ]]; then travis_retry pip install 'coverage<4.0'; fi
- travis_retry pip install tox>=1.9 coveralls
#- travis_retry tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -e test
script:
#- tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- --with-coverage
# Run tests with coverage (similar to `python -m unittest2`
# or `unit2` on Python 2.6.
- coverage run -m unittest2
after_script:
# Submit coverage to coverall.io
- coveralls --verbose
6 changes: 5 additions & 1 deletion extras_mongoengine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import fields
try:
import fields
except ImportError:
# Python 3
from . import fields

__all__ = ('fields')
2 changes: 1 addition & 1 deletion extras_mongoengine/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TimedeltaField(BaseField):
"""
def validate(self, value):
if not isinstance(value, (timedelta, int, float)):
self.error(u'cannot parse timedelta "%r"' % value)
self.error(unicode('cannot parse timedelta "%r"' % value))

def to_mongo(self, value):
return self.prepare_query_value(None, value)
Expand Down
1 change: 1 addition & 0 deletions requirements-python<3.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum34