From bfc4691d06e6c34c27badc1a0abfac12b51e96bd Mon Sep 17 00:00:00 2001 From: Stepan Rakhimov Date: Tue, 29 Nov 2016 15:25:19 +0100 Subject: [PATCH 1/4] textwrap.dedent does not expect None, but __doc__ can be None if built with -OO flag. See https://docs.python.org/2.7/using/cmdline.html#cmdoption-OO --- docx/enum/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docx/enum/base.py b/docx/enum/base.py index aad44e9c8..823496250 100644 --- a/docx/enum/base.py +++ b/docx/enum/base.py @@ -60,6 +60,8 @@ def _intro_text(self): cls_docstring = self._clsdict['__doc__'] except KeyError: cls_docstring = '' + if None == cls_docstring: + cls_docstring = '' return textwrap.dedent(cls_docstring).strip() def _member_def(self, member): From 687f29ff174d4cf5b763a4c62025d159e17bc091 Mon Sep 17 00:00:00 2001 From: Stepan Rakhimov Date: Tue, 29 Nov 2016 16:31:06 +0100 Subject: [PATCH 2/4] added extra test for previous fix. Must be run with python -OO flags for reproduction --- .gitignore | 1 + .travis.yml | 4 +++- tests/test_enum.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index de25a6f76..0c69e42d1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /docs/.build/ /*.egg-info *.pyc +*.pyo _scratch/ Session.vim /.tox/ diff --git a/.travis.yml b/.travis.yml index 3345ff24f..e8d80fdc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,6 @@ python: # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: pip install -r requirements.txt # command to run tests, e.g. python setup.py test -script: py.test +script: + - py.test + - python -OO -m py.test tests/test_enum.py diff --git a/tests/test_enum.py b/tests/test_enum.py index edfe595dc..bc3e12c47 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -77,6 +77,9 @@ def it_knows_if_a_setting_is_valid(self): def it_can_be_referred_to_by_a_convenience_alias_if_defined(self): assert BARFOO is FOOBAR # noqa + def it_provides_doc(self): + assert(FOOBAR.__docs_rst__) + class DescribeEnumValue(object): From c52f0528c722a21b9932dbd163f79440ae6b2806 Mon Sep 17 00:00:00 2001 From: Stepan Rakhimov Date: Tue, 29 Nov 2016 16:38:23 +0100 Subject: [PATCH 3/4] added python 3.5 to test runs --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e8d80fdc3..69b78e622 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: python python: + - "3.5" - "3.4" - "3.3" - "2.7" From 1a9d730cef1e52176375a79e3f25698948889903 Mon Sep 17 00:00:00 2001 From: Stepan Rakhimov Date: Tue, 29 Nov 2016 16:51:14 +0100 Subject: [PATCH 4/4] exclude python 3.3 and 3.5 from -OO test --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69b78e622..0db6b1167 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,14 @@ python: # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: pip install -r requirements.txt # command to run tests, e.g. python setup.py test -script: - - py.test - - python -OO -m py.test tests/test_enum.py +script: py.test + +# run python -OO on certain versions only, 3.3 and 3.5 cannot handle this +matrix: + include: + - python: "2.6" + script: python -OO -m py.test tests/test_enum.py + - python: "2.7" + script: python -OO -m py.test tests/test_enum.py + - python: "3.4" + script: python -OO -m py.test tests/test_enum.py