Some assert functions are renamed/missing in various Python versions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testtools |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Documentation for unittest in PY2/PY3:
https:/
https:/
For example, to do a fuzzy-comparison of two collections:
Python 2.7 unittest includes unittest.
Python 3.2+ unittest includes unittest.
Python 2.6 unittest does not include either of these functions.
As far as I can tell, there's nothing in `six` to handle this. I've had to work around the problem in my own classes that implement testtools.TestCase, using the following:
if hasattr(
# If this function is available, do nothing (PY27)
pass
elif hasattr(
# If this function is available, alias it (PY32+)
assertItems
else:
# If neither is available, make our own version (PY26, PY30-31?)
def assertItemsEqua
# Custom implementation is here
I believe this should be handled at the testtools layer.
Expected functionality for any version of Python (assuming the best option is to just make both names available):
self.assertItem
self.assertCoun
Actual functionality:
Py26: self.assertItem
Py27: self.assertItem
Py31: self.assertItem
Py32+: self.assertItem
Py26: self.assertCoun
Py27: self.assertCoun
Py31: self.assertCoun
Py32+: self.assertCoun
Most of the functions that are missing from unittest in Python 2.6.x are available via unittest2.