couchdb-python
couchdb-python copied to clipboard
Unittests get unicode in python 2.6
From [email protected] on August 05, 2010 20:09:05
Python Unittests fail on python 2.6 (haven't tested other pythons) because the doctests expect strings and get unicode.
Attached is a patch which makes the tests pass.
Attachment: couchdb.diff
Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=144
From djc.ochtman on August 07, 2010 07:39:51
Yeah, this is a problem with different JSON libraries. The standard library json returns unicode, but simplejson doesn't. I'm not sure there's an easy way out here.
Labels: -Priority-Medium Priority-Low
From [email protected] on October 09, 2012 11:12:34
I would like to change the doctests so that the tests fail on older versions of python, rather than newer.
Reasoning is that fewer and fewer people are going to be using old versions of python as time goes on, and backwards compat with 2.5 will be less and less important (I am of the opinion that it's of zero importance now, because anyone using python 2.5 with couchdb-python is probably not in a position to upgrade couchdb-python either).
In any case, I'm going to work up a patch even if it won't be accepted, because I can't run the tests as-is, and I'm not going to install 2.5 in my dev environment.
From [email protected] on October 09, 2012 12:03:41
make test
passes under python 2.7.3.
I had to hg diff -b -r default > doctest_unicode.patch
since the repo currently has trailing whitespace (seems like only on blank lines?).
Status: Fixed
Attachment: doctest_unicode.patch
From djc.ochtman on October 10, 2012 00:27:11
Ah, but it's not just older vs. newer. It's also python with simplejson installed vs without. And since I would presume most serious CouchDB users to have simplejson installed (since AFAIK there's a big performance diff between 2.7 stdlib json and latest simplejson), I don't think this is a good patch to take.
Also, please don't mark issues as fixed until they've been committed.
Status: Accepted
From kxepal on October 10, 2012 01:24:08
I wonder could there be used experience from this thread: http://mail.python.org/pipermail/python-dev/2010-March/098166.html also u'...' strings in doctests will make harder to add python 3.x support in future.
From kxepal on October 10, 2012 01:37:27
Related issue thread in project: https://bitbucket.org/fiji/django-3k/issue/6/resolve-issue-with-unicode-test-cases Probably, there could be done similar trick based not on python version, but on json module that does/doesn't emits unicode string.