Skip to content

Fix unit tests on Python3 and keep them OK on Python2.7 - #720

Closed
HelioGuilherme66 wants to merge 1 commit into
robotframework:masterfrom
HelioGuilherme66:fix_unit_tests_py3
Closed

HelioGuilherme66 wants to merge 1 commit into
robotframework:masterfrom
HelioGuilherme66:fix_unit_tests_py3

Conversation

@HelioGuilherme66

Copy link
Copy Markdown
Member
  • Formatting of exceptions messages
  • Definition of unicode method on Python 3.x

@HelioGuilherme66

Copy link
Copy Markdown
Member Author

Please merge this one to have Travis builds green again. Later we can optimize the "unicode" in Python 3.x.

@pekkaklarck

Copy link
Copy Markdown
Member

The approach to handle unicode is not correct. It perhaps makes unit tests pass but it won't actually work correctly. Not sure yet what's the best solution to this, but committing broken implememtation wouldn't make sense.

Actual unit test fixes could be done already now, but converting exceptions to strings should be done using str(). Should actually use unicode() to support non-ASCII on Py2, but on unit tests we could just assume everything to be ASCII.

@alexandrul

Copy link
Copy Markdown

This approach would be ok?
https://github.com/oxplot/fysom/issues/1
http://www.rfk.id.au/blog/entry/preparing-pyenchant-for-python-3/

@aaltat

aaltat commented Dec 28, 2016

Copy link
Copy Markdown
Contributor

Thanks from the link, need to read it with more thought.

@HelioGuilherme66

Copy link
Copy Markdown
Member Author

@pekkaklarck Please see if you agree with the TODAY's change to use robot.utils PY3 and unic().

@pekkaklarck

Copy link
Copy Markdown
Member

No, I don't agree with them:

  • Using PY3 directly would create a dependency to RF 3.0 or newer.
  • Should never define unicode as a custom method because it won't work with isinstance. unicode = str is better.
  • Imports are not PEP-8 compatible.
  • "{}".format(e) is a strange way to format an exception. str(e) is totally fine in tests. In production code should think about the possibility that e may contain non-ASCII characters.

@HelioGuilherme66

Copy link
Copy Markdown
Member Author

I have run out of ideas. Please post solution for the unicode problem.

@pekkaklarck

Copy link
Copy Markdown
Member

I'm not sure yet what's the best solution for handling unicode/str/bytes stuff in this library. The solution may in fact be different in different places, most importantly different in the real library code and in unit tests. I hope I have time for Se2Lib next week ,but I'll start from the architecture changes @aaltat and I have discussed.

Defines unicode on Python 3.x to be compatible with Python 2.7.
HelioGuilherme66 referenced this pull request in HelioGuilherme66/robotframework-seleniumlibrary Jan 29, 2017
There are entries obsolete or overridden by others.
The goal is to keep Selenium2Library compatible with Python 2.7 and 3.x.

There is still discussion on the best way to solve compatability problems,
like for example, 'unicode'. See https://github.com/robotframework/Selenium2Library/pull/720 for more info on this.

Commits entries:
Changes to Travis settings to allow installation dependent on Python versions.
Transformed print statement into function. Compatible with Python 2.6.
Fixes import to be compatible with RobotFramework 3.0.
Changes Travis settings to install RobotFramework 3.0.
Separates imports per line, for better code readability.
Adds 'future' dependency and information to install it.
Upgrades Travis firefox to latest-esr.
Fixes ez_setup.py. Changes version to 1.8.0b2.
Removes selenium version dependency, current version is 2.53.2.
Add GitHub process files.
Update CONTRIBUTING.md
Fixed Issues URL to point to my fork.
Update ISSUE_TEMPLATE.md
Fix typo
Libdoc updates - link to project and fix 404 (robotframework#668)
* Fix 404 due to RF migration to Github
* Link to project page
* Format corrections per PR comments
* fix pronoun usage
Added method to find element by class name robotframework#673 (robotframework#674)
* Added method to find element by class name robotframework#673
* Changes to use Firefox ESR (45.4.0)
While we are not having Selenium 3.0 working, with external `geckodriver`, we use lower versions of stable Firefox.
* Changes to use Selenium 2.53.6 (and not 3.0)
We are not ready for Selenium 3.0 yet.
Updated Travis config.
Fixes installer for both Python 2.7 and 3.x.
@aaltat

aaltat commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

This issue is already fixed in master, therefore closing the PR.

@aaltat aaltat closed this Jun 28, 2017
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.

4 participants