From bc4e8deaa2415ec7551280f3b6e0a763afc54b87 Mon Sep 17 00:00:00 2001 From: Jan Vollmer <51451323+kreyoo@users.noreply.github.com> Date: Mon, 3 Jan 2022 09:50:59 +0100 Subject: [PATCH 1/4] element.getchildren() was removed The method was removed with version 3.9 of the standard library: https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren --- genshi/input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genshi/input.py b/genshi/input.py index 48ee193..fa18c38 100644 --- a/genshi/input.py +++ b/genshi/input.py @@ -45,7 +45,7 @@ def ET(element): yield START, (tag_name, attrs), (None, -1, -1) if element.text: yield TEXT, element.text, (None, -1, -1) - for child in element.getchildren(): + for child in element: for item in ET(child): yield item yield END, tag_name, (None, -1, -1) From 5cdc6fd715f2b6207b620e82d283c2ed9f336490 Mon Sep 17 00:00:00 2001 From: kreyoo Date: Tue, 4 Jan 2022 22:34:59 +0100 Subject: [PATCH 2/4] add .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da8cbad --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.egg-info +build +*.so +__pycache__ \ No newline at end of file From cad6f66342445a9a6389143154cc473790a7cfe6 Mon Sep 17 00:00:00 2001 From: kreyoo Date: Tue, 4 Jan 2022 22:35:12 +0100 Subject: [PATCH 3/4] test on pull requests --- .github/workflows/tests.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24d5801..c9a6135 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,22 +1,21 @@ name: run -on: [push] +on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.6, 3.7, 3.8, 3.9, '3.10', pypy2, pypy3] + python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10", pypy2, pypy3] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Run test suite - run: | - python setup.py test + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Run test suite + run: | + python setup.py test From ebbe252f9de914603eb91a701890fd974d8aec81 Mon Sep 17 00:00:00 2001 From: Jan Vollmer Date: Wed, 5 Jan 2022 14:31:48 +0100 Subject: [PATCH 4/4] test the conversion from ElmentTree to markup stream --- genshi/tests/input.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/genshi/tests/input.py b/genshi/tests/input.py index e520e26..fbee840 100644 --- a/genshi/tests/input.py +++ b/genshi/tests/input.py @@ -13,11 +13,11 @@ import unittest -from genshi.core import Attrs, Stream -from genshi.input import XMLParser, HTMLParser, ParseError +from genshi.core import Attrs, QName, Stream +from genshi.input import XMLParser, HTMLParser, ParseError, ET from genshi.compat import StringIO, BytesIO from genshi.tests.test_utils import doctest_suite - +from xml.etree import ElementTree class XMLParserTestCase(unittest.TestCase): @@ -278,6 +278,21 @@ def test_multibyte_character_on_chunk_boundary(self): self.assertEqual(1, len(events)) self.assertEqual((Stream.TEXT, text), events[0][:2]) + def test_convert_ElementTree_to_markup_stream(self): + tree = ElementTree.fromstring( + u'
textsome more text
' + ) + events = list(ET(tree)) + self.assertEqual(6, len(events)) + self.assertEqual( + (Stream.START, (QName("div"), Attrs([(QName("class"), "test_div")]))), + events[0][:2], + ) + self.assertEqual((Stream.TEXT, "text"), events[1][:2]) + self.assertEqual((Stream.START, (QName("span"), Attrs())), events[2][:2]) + self.assertEqual((Stream.TEXT, "some more text"), events[3][:2]) + self.assertEqual((Stream.END, QName("span")), events[4][:2]) + self.assertEqual((Stream.END, QName("div")), events[5][:2]) def suite(): suite = unittest.TestSuite()