Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testsuite Python 2/3 compatible #7

Merged
merged 15 commits into from
Mar 1, 2019
Merged

Make testsuite Python 2/3 compatible #7

merged 15 commits into from
Mar 1, 2019

Conversation

d-maurer
Copy link
Contributor

  • Handling of unicode literal string prefix in doctests

    • partly avoided by an explicit conversion to str (usually for ASCII values)
    • test partly replaced by a comparison with a unicode literal string (usually for non ASCII values)
  • the "cgi" module of Python 3 and Python 2 behave differently for a two small "Content-Length" value
    Py 3: everything above this value is ignored; some data not processed
    Py 2: the value is ignored; all data processed
    To cope with this difference, the "http" function has been replaced by an auxiliary "http_request" function in some tests. "http_request" computes "Content-Length" correctly.

  • the test framework (--> "http", "browser") expects different input types for Python 3 and Python 2
    Py 3: text
    Py 2: utf-8 encoded binary strings
    To cope with this difference, input values have been specified by explicit unicode literals (supported by both Python 3 and Python 2) and converted to the required type via an auxiliary "to_input" function.

* Handling of unicode literal string prefix in doctests
  - partly avoided by an explicit conversion to `str` (usually for ASCII values)
  - test partly replaced by a comparison with a unicode literal string (usually for non ASCII values)

* the "cgi" module of Python 3 and Python 2 behave differently for a two small "Content-Length" value
    Py 3: everything above this value is ignored; some data not processed
    Py 2: the value is ignored; all data processed
  To cope with this difference, the "http" function has been replaced by an auxiliary "http_request" function in some tests. "http_request" computes "Content-Length" correctly.

* the test framework (--> "http", "browser") expects different input types for Python 3 and Python 2
    Py 3: text
    Py 2: utf-8 encoded binary strings
  To cope with this difference, input values have been specified by explicit unicode literals (supported by both Python 3 and Python 2) and converted to the required type via an auxiliary "to_input" function.
Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for resolving this issue. I like your code changes.

Additionally the following files should be changed resp. added:

  • setup.py – the trove classifiers (This package should support the same versions as Zope)
  • travis.yml – so that the newly supported Python versions are tested, see z3c.wizard as an example how I would do it nowadays
  • tox.ini – This file should be added to be able to run the tests locally against multiple Python versions see z3c.table as an example.
  • .coveragerc – This file should be added to configure coverage see z3c.table

src/five/formlib/tests/formlib.txt Outdated Show resolved Hide resolved
src/five/formlib/tests/formlib.txt Outdated Show resolved Hide resolved
src/five/formlib/tests/formlib.txt Outdated Show resolved Hide resolved
src/five/formlib/tests/forms.txt Outdated Show resolved Hide resolved
src/five/formlib/tests/test_formlib.py Outdated Show resolved Hide resolved
Copy link
Member

@sallner sallner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work you put into this project.

src/five/formlib/tests/test_formlib.py Show resolved Hide resolved
@d-maurer
Copy link
Contributor Author

@icemac The Travis integration problems are likely caused by outdated versions of Persistence and RestrictedPython:

accesscontrol 4.0b6 has requirement Persistence>=3.0a3, but you'll have persistence 2.13.2 which is incompatible.
accesscontrol 4.0b6 has requirement RestrictedPython>=4.0a1, but you'll have restrictedpython 3.6.0 which is incompatible.
documenttemplate 3.0b5 has requirement RestrictedPython>=4.0a1, but you'll have restrictedpython 3.6.0 which is incompatible.

However, I have no idea how I can force the Travis environment to use the correct versions.

@icemac
Copy link
Member

icemac commented Feb 28, 2019

@d-maurer With these changes (see attached patch) locally Python 2.7 and 3.5 run successfully. (Newer Python versions fail with AttributeError: __index__ in ZPublisher/HTTPResponse:509

This most important point is the pip_pre = true which allows to install beta versions of the packages.

t.patch.txt

Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hint should make it possible to run successfully on travis ci.

.travis.yml Outdated Show resolved Hide resolved
@d-maurer
Copy link
Contributor Author

@icemac Thank you: with the --pre, at least the Python 2.7 tests have been successful. I will now add the other Python 3 tests again.

.travis.yml Outdated Show resolved Hide resolved
….7 is not installed; attempting download` and the download fails
…version - use explicitely Python 3.7 from `xenial`
@d-maurer d-maurer requested a review from icemac February 28, 2019 09:03
Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor suggestions.

CHANGES.rst Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@d-maurer d-maurer merged commit b76d68d into zopefoundation:master Mar 1, 2019
@icemac
Copy link
Member

icemac commented Mar 5, 2019

@d-maurer Thank you very much!

@icemac icemac added this to In progress in Zope 4 final release via automation Mar 5, 2019
@icemac icemac moved this from In progress to Postponed or Rejected in Zope 4 final release Mar 5, 2019
@icemac icemac moved this from Postponed or Rejected to Done in Zope 4 final release Mar 5, 2019
@icemac
Copy link
Member

icemac commented Mar 5, 2019

Released to PyPI: https://pypi.org/project/five.formlib/2.1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants