diff --git a/.travis.yml b/.travis.yml index 6a1a2da..ff54aaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,27 @@ python: - "2.7" # - "pypy" +cache: "pip" + +# Enable newer 3.7 without globally enabling sudo and dist: xenial for other build jobs +matrix: + allow_failures: + - python: "3.4" + - python: "3.5" + include: + - python: 3.7 + dist: xenial + sudo: true + # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors +before_install: + - sudo apt-get install -y gcc-4.7 g++-4.7 libicu-dev install: - - sudo apt-get install gcc-4.7 g++-4.7 python-numpy libicu-dev - - pip install -r requirements.txt + - pip install -r dev-requirements.txt + - pip install polyglot # command to run tests, e.g. python setup.py test -script: nosetests +script: py.test -rfs --cov=polyglot --cov-report term-missing --cov-report xml +after_success: + - ls + - coveralls \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..1ae90ef --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,5 @@ +-r requirements.txt +pytest +coverage>=4.4 +pytest-cov +coveralls diff --git a/docs/README.rst b/docs/README.rst index b0e4b32..7927d86 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -2,7 +2,7 @@ polyglot ======== -|Downloads| |Latest Version| |Build Status| |Documentation Status| +|Downloads| |Latest Version| |Build Status| |Documentation Status| |Code Coverage Status| .. |Downloads| image:: https://img.shields.io/pypi/dm/polyglot.svg :target: https://pypi.python.org/pypi/polyglot @@ -12,6 +12,8 @@ polyglot :target: https://travis-ci.org/aboSamoor/polyglot .. |Documentation Status| image:: https://readthedocs.org/projects/polyglot/badge/?version=latest :target: https://readthedocs.org/builds/polyglot/ +.. |Code Coverage Status| image:: https://coveralls.io/repos/github/aboSamoor/polyglot/badge.svg?branch=master + :target: https://coveralls.io/github/aboSamoor/polyglot?branch=master Polyglot is a natural language pipeline that supports massive multilingual applications. diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..51e4dcb --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +test_basic +---------------------------------- + +basic tests for `polyglot` module. +""" + +import pytest +import polyglot + + +@pytest.mark.xfail() +@pytest.mark.parametrize( + "text_input,expected_code,expected_name", + [ + ("Bonjour, Mesdames.", "fr", "French"), + ("Preprocessing is an essential step.", "en", "English"), + ], +) +def test_language_detection(text_input, expected_code, expected_name): + from polyglot.text import Text + + poly_text = polyglot.Text(text_input) + assert poly_text.language.code == expected_code + assert poly_text.language.name == expected_lang + + +if __name__ == "__main__": + pytest.main(["-vv"]) diff --git a/tests/test_polyglot.py b/tests/test_polyglot.py deleted file mode 100755 index 616c443..0000000 --- a/tests/test_polyglot.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -test_polyglot ----------------------------------- - -Tests for `polyglot` module. -""" - -import unittest - -from polyglot import polyglot - - -class TestPolyglot(unittest.TestCase): - - def setUp(self): - pass - - def test_something(self): - pass - - def tearDown(self): - pass - -if __name__ == '__main__': - unittest.main() \ No newline at end of file diff --git a/tests/test_smoke.py b/tests/test_smoke.py new file mode 100644 index 0000000..dc97109 --- /dev/null +++ b/tests/test_smoke.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +test_smoke +---------------------------------- + +smoke tests for `polyglot` module. +""" + +import pytest + + +def test_for_fire(): + """Make sure nothing blows up while importing polyglot""" + import polyglot + + +if __name__ == "__main__": + pytest.main(["-v"])