From d759c9d43743ca85a1fc773ae5bb4f1f7947a3b8 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 18:28:41 -0500 Subject: [PATCH 1/6] Add support for Python 3.5 Also include a fix for one failing test with HTMLParser. Three additional tests are still failing for a differant problem related to search. --- mkdocs/toc.py | 7 +++++++ tox.ini | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mkdocs/toc.py b/mkdocs/toc.py index c00dabee..75172cb1 100644 --- a/mkdocs/toc.py +++ b/mkdocs/toc.py @@ -64,6 +64,13 @@ class TOCParser(HTMLParser): self.in_anchor = False self.attrs = None self.title = '' + + # Prior to Python3.4 no convert_charrefs keyword existed. + # However, in Python3.5 the default was changed to True. + # We need the False behavior in all versions but can only + # set it if it exists. + if hasattr(self, 'convert_charrefs'): + self.convert_charrefs = False def handle_starttag(self, tag, attrs): diff --git a/tox.ini b/tox.ini index d0424765..d271241d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,17 @@ [tox] envlist = - py{26,27,33,34}-{unittests,integration,min-req}, + py{26,27,33,34,35}-{unittests,integration,min-req}, flake8 [testenv] passenv = LANG deps= - py{26,27,33,34,py,py3}-{unittests,integration}: -rrequirements/project.txt - py{26,27,33,34,py,py3}-min-req: -rrequirements/project-min.txt - py{26,27,33,34,py,py3}-{unittests,min-req}: -rrequirements/test.txt + py{26,27,33,34,35,py,py3}-{unittests,integration}: -rrequirements/project.txt + py{26,27,33,34,35,py,py3}-min-req: -rrequirements/project-min.txt + py{26,27,33,34,35,py,py3}-{unittests,min-req}: -rrequirements/test.txt commands= - py{26,27,33,34,py,py3}-{unittests,min-req}: {envbindir}/nosetests --with-coverage --cover-package mkdocs mkdocs - py{26,27,33,34,py,py3}-integration: {envpython} -m mkdocs.tests.integration --output={envtmpdir}/builds + py{26,27,33,34,35,py,py3}-{unittests,min-req}: {envbindir}/nosetests --with-coverage --cover-package mkdocs mkdocs + py{26,27,33,34,35,py,py3}-integration: {envpython} -m mkdocs.tests.integration --output={envtmpdir}/builds [testenv:flake8] deps=-rrequirements/test.txt From b87d2bf552c0cf7e15c50ce27a3ac98db6634682 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 19:10:34 -0500 Subject: [PATCH 2/6] Remaining tests pass on Python 3.5 The `search.ContentParser` (a HTMLParser subclass) should always be closed to force parsing of all buffered data. The three low-level tests now close the parser manually. However, a call to close was also added to the higher level SearchIndex class. --- mkdocs/search.py | 1 + mkdocs/tests/search_tests.py | 3 +++ mkdocs/toc.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mkdocs/search.py b/mkdocs/search.py index f4006b51..10a92b8a 100644 --- a/mkdocs/search.py +++ b/mkdocs/search.py @@ -53,6 +53,7 @@ class SearchIndex(object): # us to iterate through it. parser = ContentParser() parser.feed(content) + parser.close() # Get the absolute URL for the page, this is then # prepended to the urls of the sections diff --git a/mkdocs/tests/search_tests.py b/mkdocs/tests/search_tests.py index f6343134..b4dbf911 100644 --- a/mkdocs/tests/search_tests.py +++ b/mkdocs/tests/search_tests.py @@ -28,6 +28,7 @@ class SearchTests(unittest.TestCase): parser = search.ContentParser() parser.feed('

Title

TEST') + parser.close() self.assertEquals(parser.data, [search.ContentSection( text=["TEST"], @@ -40,6 +41,7 @@ class SearchTests(unittest.TestCase): parser = search.ContentParser() parser.feed("

Title

TEST") + parser.close() self.assertEquals(parser.data, [search.ContentSection( text=["TEST"], @@ -52,6 +54,7 @@ class SearchTests(unittest.TestCase): parser = search.ContentParser() parser.feed("Content Before H1

Title

TEST") + parser.close() self.assertEquals(parser.data, [search.ContentSection( text=["TEST"], diff --git a/mkdocs/toc.py b/mkdocs/toc.py index 75172cb1..b051201b 100644 --- a/mkdocs/toc.py +++ b/mkdocs/toc.py @@ -64,7 +64,7 @@ class TOCParser(HTMLParser): self.in_anchor = False self.attrs = None self.title = '' - + # Prior to Python3.4 no convert_charrefs keyword existed. # However, in Python3.5 the default was changed to True. # We need the False behavior in all versions but can only From 1f561c6979862e7ad0135e3b9820006dd02a6dde Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 19:26:36 -0500 Subject: [PATCH 3/6] Include Py35 tests in CI tests. --- .travis.yml | 3 +++ appveyor.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index a8b001dc..76216561 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,9 @@ env: - TOXENV=py34-integration - TOXENV=py34-min-req - TOXENV=py34-unittests +- TOXENV=py35-integration +- TOXENV=py35-min-req +- TOXENV=py35-unittests - TOXENV=pypy-integration - TOXENV=pypy-min-req - TOXENV=pypy-unittests diff --git a/appveyor.yml b/appveyor.yml index 9263440c..cad24eef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,9 @@ environment: - TOXENV: py34-integration - TOXENV: py34-min-req - TOXENV: py34-unittests + - TOXENV: py35-integration + - TOXENV: py35-min-req + - TOXENV: py35-unittests - TOXENV: flake8 init: - "ECHO %TOXENV%" From 3c0849b0d7f07ee50940a62e7cf5a264ebdc8cbf Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 19:49:45 -0500 Subject: [PATCH 4/6] Switch Travis to use new container-based infrastructure. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 76216561..0b8525a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: false language: python python: '2.7' env: From 2eb7b23941dcda44e6c910186aec76ef8bbc8f43 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 20:08:08 -0500 Subject: [PATCH 5/6] Force Travis to use Python3.5. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b8525a1..b3cf983e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false language: python -python: '2.7' +python: '3.5' env: - TOXENV=py26-integration - TOXENV=py26-min-req From 74953f29954f5bdb750de12593e60afe128c534d Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 17 Nov 2015 20:30:09 -0500 Subject: [PATCH 6/6] Force tox to use Py26 for Flake8 env. WHen Flake8 is run in Python3, it will fail on "undefined" objects which are onlu used in if statements that run on Python2. As a workaround, force tox to use Python2 when running Flake8. This can just be removed in the future if/when Python2 support is dropped. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index d271241d..d5377501 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ commands= py{26,27,33,34,35,py,py3}-integration: {envpython} -m mkdocs.tests.integration --output={envtmpdir}/builds [testenv:flake8] +basepython = python2.7 deps=-rrequirements/test.txt commands={envbindir}/flake8 mkdocs --max-line-length=119 --exclude=mkdocs/compat.py