Skip to content

Commit

Permalink
Add tox as test runner + update Travis configuration.
Browse files Browse the repository at this point in the history
The new test runner is needed as Travis does not know `python2` and `python3`.
(BTW I have the same problem on my computer, so I cannot use the previous
approach with the Makefile without modifications on my system.)

The tests in grammar/test_grammar.py are not run because I was not able to find
out how to run `make` in the `grammar` directory before installing the package.

See https://tox.readthedocs.io for documentation on tox and
https://docs.pytest.org for documentation on pytest. (These tools are widely
used in the Python community and would make it easier for contributors to run
the tests.)

I had to fix two tests to be able to run them successfully.
  • Loading branch information
Michael Howitz committed Jun 15, 2017
1 parent 223a7b5 commit 2407640
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build/
*.pyc
.tox/
.cache/
*.egg-info/
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
install:
- pip install tox-travis
script:
- tox
8 changes: 7 additions & 1 deletion HOWTODIST
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ $ cd odfpy

Run the automated tests:

$ cd tests ; make ; cd ..
Install `tox` via `pip` when running the tests for the first time:

$ pip install tox

Run the tests for all supported python versions:

$ tox

Remove the "dev" marker from the version in setup.py and odf/namespaces.py

Expand Down
2 changes: 0 additions & 2 deletions setup

This file was deleted.

7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[bdist_wheel]
universal=1

[tool:pytest]
norecursedirs = grammar
addopts = tests
python_files = test*.py
10 changes: 0 additions & 10 deletions tests/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions tests/runtests

This file was deleted.

4 changes: 2 additions & 2 deletions tests/teststyles.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def testAttributeForeign(self):
textdoc.styles.addElement(standard)
s = textdoc.stylesxml()
s.index(u"""<?xml version='1.0' encoding='UTF-8'?>\n""")
s.index(u'xmlns:ns41="http://foreignuri.com"')
s.index(u'<style:paragraph-properties ns41:enable-numbering="true"/>')
s.index(u'xmlns:ns44="http://foreignuri.com"')
s.index(u'<style:paragraph-properties ns44:enable-numbering="true"/>')
e = ElementParser(s,u'style:style')
# e = ElementParser('<style:style style:name="Standard" style:display-name="Standard" style:family="paragraph">')
self.assertEqual(e.element,u'style:style')
Expand Down
2 changes: 2 additions & 0 deletions tests/testunicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def assertContains(self, stack, needle):
def assertNotContains(self, stack, needle):
self.assertEqual(-1, stack.find(needle))

@unittest.skipIf(sys.version_info[0] != 2,
"For Python3, unicode strings are type 'str'.")
def test_xstyle(self):
self.assertRaises(UnicodeDecodeError, style.Style, name="X✗", family="paragraph")
xstyle = style.Style(name=u"X✗", family=u"paragraph")
Expand Down
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tox]
envlist =
py27,
py33,
py34,
py35,
py36,

[testenv]
commands =
pytest
deps =
pytest

0 comments on commit 2407640

Please sign in to comment.