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

Fix tests to be compatible for both python2 and python3 #839

Merged
merged 2 commits into from Sep 27, 2017

Conversation

Projects
None yet
2 participants
@tonysun83
Contributor

tonysun83 commented Sep 26, 2017

Overview

We make mango tests python2 and python3 compatible.

Testing recommendations

Tests were run successfully in python2 and python3 environments. To run nosetests with python3:

  1. pyvenv myenv
  2. source myenv/bin/activate
  3. pip install nose
  4. python3 -m "nose"

GitHub issue number

#834

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;
fix tests to be compatible for both python2 and python3
We change syntax issues that make the tests incompatible for python3
but also ensure that it still runs using python2.
@@ -44,7 +44,7 @@ def url(self):
return "http://{}:{}/{}".format(self.host, self.port, self.dbname)
def path(self, parts):
if isinstance(parts, (str, unicode)):
if isinstance(parts, ("".__class__, u"".__class__)):

This comment has been minimized.

@tonysun83

tonysun83 Sep 26, 2017

Contributor

only part worth of note. Another way to do this is :

try:
    basestring
except NameError:
    basestring = str

isinstance(s, basestring)
@tonysun83

tonysun83 Sep 26, 2017

Contributor

only part worth of note. Another way to do this is :

try:
    basestring
except NameError:
    basestring = str

isinstance(s, basestring)

This comment has been minimized.

@wohali

wohali Sep 26, 2017

Member

Cute shortcut, makes perfect sense.

@wohali

wohali Sep 26, 2017

Member

Cute shortcut, makes perfect sense.

@wohali

wohali approved these changes Sep 26, 2017

@@ -44,7 +44,7 @@ def url(self):
return "http://{}:{}/{}".format(self.host, self.port, self.dbname)
def path(self, parts):
if isinstance(parts, (str, unicode)):
if isinstance(parts, ("".__class__, u"".__class__)):

This comment has been minimized.

@wohali

wohali Sep 26, 2017

Member

Cute shortcut, makes perfect sense.

@wohali

wohali Sep 26, 2017

Member

Cute shortcut, makes perfect sense.

@wohali

This comment has been minimized.

Show comment
Hide comment
@wohali

wohali Sep 27, 2017

Member

@tonysun83 Jenkins desperately needs these changes so I'm pushing the merge button. Hope you're OK with that ;)

Member

wohali commented Sep 27, 2017

@tonysun83 Jenkins desperately needs these changes so I'm pushing the merge button. Hope you're OK with that ;)

@wohali wohali merged commit 355f0fc into master Sep 27, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@wohali wohali deleted the make-mango-python3-compile branch Sep 27, 2017

wohali added a commit that referenced this pull request Oct 19, 2017

fix tests to be compatible for both python2 and python3 (#839)
We change syntax issues that make the tests incompatible for python3
but also ensure that it still runs using python2.

willholley added a commit to willholley/couchdb that referenced this pull request May 22, 2018

fix tests to be compatible for both python2 and python3 (#839)
We change syntax issues that make the tests incompatible for python3
but also ensure that it still runs using python2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment