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

[WIP] - Update tests #51

Draft
wants to merge 4 commits into
base: python3
Choose a base branch
from
Draft

[WIP] - Update tests #51

wants to merge 4 commits into from

Conversation

cekk
Copy link
Contributor

@cekk cekk commented Aug 11, 2020

I've updated tests to be aligned with modern ones.

There are some old doctests that i haven't migrated yet because i don't know what could be a good strategy for them. Any suggestions?

Right now i enabled tests only for Plone 5.2..should we have to keep a backward compatibility?

@cekk cekk marked this pull request as draft August 11, 2020 12:27
@cekk cekk requested a review from abosio August 11, 2020 12:27
@abosio
Copy link
Contributor

abosio commented Aug 11, 2020

Thanks so much! I am not a great reviewer for tests. Hopefully @mauritsvanrees will get a chance to look at this.

@abosio abosio removed their request for review August 11, 2020 12:35
.python-version Outdated Show resolved Hide resolved
# env: PLONE_VERSION=43
# - python: "2.7"
# env: PLONE_VERSION=51
# - python: "2.7"
Copy link
Member

Choose a reason for hiding this comment

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

I think the -python "2.7" line still needs to be there, otherwise the structure differs from the python3.7/plone52 below it.

Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

This is far too big to review in depth. But I have glanced at the changes, and added some minor comments, but for the rest it looks good.

Does this include the changes from the python3 branch?

I would indeed say: test this only on Plone 5.2, and both Python 2 and 3. (I guess for Python 3 it is enough to only test on 3.7, not on 3.6.)

But I am not using Poi anymore. (Except maybe still an old version with Plone 4, on a customer server that I cannot reach.)

.travis.yml Outdated Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
.travis.yml Outdated
after_success:
- bin/createcoverage --output-dir=parts/test/coverage
- bin/pip install coverage
- bin/python -m coverage.pickle2json
Copy link
Member

Choose a reason for hiding this comment

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

I think pickle2json is not needed anymore, and may break. But not sure.
I don't know if the current coverage setup is okay. I have seen lots of projects where it is not, where a coverage report might be created just fine, but the sending to coveralls fails, probably because the project has not been registered yet. I have not cared enough to check for those projects. Maybe it is fine here.

Products/Poi/tests/base.py Outdated Show resolved Hide resolved
@cekk
Copy link
Contributor Author

cekk commented Aug 25, 2020

Thanks @mauritsvanrees.
I disabled python2 tests because there are some broken imports (urllib for example) that need to be fixed if we want to keep a backward compatibility with python2.

Personally i don't need python2 compatibility because we are porting to plone 52 the (few) sites that is using Poi.

Could be a good approach remove python2 compatibility in master version, and keep a python2 branch (the current master) for people that still need it?

I still don't know how to convert old-style doctests (into old-tests folder)..any ideas or best practices here?

@mauritsvanrees
Copy link
Member

When you migrate a site with Poi from Plone 5.1 to 5.2 with the standard inline migration, it goes like this:

  1. Migrate to 5.2 on Python 2.7, run the Plone upgrade and any add-on upgrades.
  2. Migrate the Data.fs to Python 3.

You cannot skip the first step. So Poi must work with Python 2.
Technically, the site only needs to startup without errors, and any Poi upgrades should be able to run, even if the views may contain Python2-only errors. We did that when migration Poi from Archetypes on 4.3 to Dexterity on 5.0: there was a mandatory intermediate step migration to Dexterity on 4.3 where the views did not work.

Fixing a few imports should not be so much work. Some helpful documentation:

But yes, getting tests to run on both can in some cases be a PITA.
Especially doctests. There it helps to use a helper class Py23DocChecker to smooth away differences in output between Python 2 and 3, like here in CMFPlone.
Also, using print(...) a lot helps, otherwise on Python 2 the expected output may be unicode, and on Python 3 a string, and that does not help.

For converting to plain unittests: try to split it up. Most doctest files contain several scenarios with some common setup.

@cekk cekk changed the base branch from master to python3 September 9, 2020 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants