Skip to content

Commit

Permalink
Merge pull request #86 from rfk/travis-osx
Browse files Browse the repository at this point in the history
Add osx to travis test matrix
  • Loading branch information
rfk committed Jul 18, 2017
2 parents d16cfd1 + 35e66aa commit 4f7c08c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
27 changes: 21 additions & 6 deletions .travis.yml
Expand Up @@ -2,18 +2,33 @@ sudo: false

language: python

python:
- "2.6"
- "2.7"
- "3.4"
- "3.5"
- "pypy"
matrix:
include:
# OSX doesn't work with `language: python` yet
- os: osx
language: generic
- os: linux
python: 2.6
- os: linux
python: 2.7
- os: linux
python: 3.4
- os: linux
python: 3.5
- os: linux
python: pypy

addons:
apt:
packages:
- libenchant-dev

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3 enchant; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then virtualenv ./venv -p python3; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source ./venv/bin/activate; fi

script:
- python setup.py test

Expand Down
6 changes: 5 additions & 1 deletion enchant/__init__.py
Expand Up @@ -938,10 +938,14 @@ def get_enchant_version():


# Run unit tests when called from command-line
if __name__ == "__main__":
def _runtestsuite():
import sys
import enchant.tests
res = enchant.tests.runtestsuite()
if len(res.errors) > 0 or len(res.failures) > 0:
sys.exit(1)
sys.exit(0)


if __name__ == "__main__":
_runtestsuite()
16 changes: 12 additions & 4 deletions enchant/tests.py
Expand Up @@ -48,9 +48,11 @@
from enchant.utils import unicode, raw_unicode, printf, trim_suggestions


def runcmd(cmd):
def runcmd(cmd, **kwds):
if subprocess is not None:
kwds = dict(stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
kwds["stdout"] = subprocess.PIPE
kwds["stderr"] = subprocess.PIPE
kwds["shell"] = True
p = subprocess.Popen(cmd,**kwds)
(stdout,stderr) = p.communicate()
if p.returncode:
Expand Down Expand Up @@ -534,8 +536,14 @@ def runtests(self):
if str is not unicode and isinstance(insdir,unicode):
insdir = insdir.encode(sys.getfilesystemencoding())
os.environ["PYTHONPATH"] = insdir
script = os.path.join(insdir,"enchant","__init__.py")
res = runcmd("\"%s\" %s" % (sys.executable,script,))
testCmd = "import enchant, os; " \
"from os.path import abspath; " \
"import sys; from enchant.utils import printf; " \
"printf(abspath(enchant.__file__), file=sys.stderr); " \
"printf(abspath(os.curdir), file=sys.stderr); " \
"assert abspath(os.curdir) in abspath(enchant.__file__); " \
"enchant._runtestsuite()"
res = runcmd("\"%s\" -c %r" % (sys.executable, testCmd), cwd=insdir)
self.assertEqual(res,0)

def test_basic(self):
Expand Down
5 changes: 3 additions & 2 deletions enchant/tokenize/tests.py
Expand Up @@ -321,5 +321,6 @@ def test_typographic_apostrophe_en(self):
output = [(u"They\u2019re", 0), (u"here", 8)]
self.assertEqual(output, [i for i in tknzr(input)])
# Typographic apostrophe is only support for unicode inputs.
output = [("They", 0), ("re", 7), ("here", 10)]
self.assertEqual(output, [i for i in tknzr(input.encode('utf8'))])
if str is not unicode:
output = [("They", 0), ("re", 7), ("here", 10)]
self.assertEqual(output, [i for i in tknzr(input.encode('utf8'))])

0 comments on commit 4f7c08c

Please sign in to comment.