mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-22 14:22:25 +00:00
Port test_humanreadable.py to Python 3.
This commit is contained in:
parent
99b62775e9
commit
c207a0c932
3
setup.py
3
setup.py
@ -119,6 +119,9 @@ install_requires = [
|
||||
|
||||
# WebSocket library for twisted and asyncio
|
||||
"autobahn >= 19.5.2",
|
||||
|
||||
# Support for Python 3 transition
|
||||
"future >= 0.18.2",
|
||||
]
|
||||
|
||||
setup_requires = [
|
||||
|
@ -1,12 +1,17 @@
|
||||
"""Tests for allmydata.util.humanreadable."""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import *
|
||||
from twisted.trial import unittest
|
||||
|
||||
from allmydata.util import humanreadable
|
||||
|
||||
|
||||
|
||||
|
||||
def foo(): pass # keep the line number constant
|
||||
|
||||
|
||||
@ -17,7 +22,7 @@ class NoArgumentException(Exception):
|
||||
class HumanReadable(unittest.TestCase):
|
||||
def test_repr(self):
|
||||
hr = humanreadable.hr
|
||||
self.failUnlessEqual(hr(foo), "<foo() at test_humanreadable.py:10>")
|
||||
self.failUnlessEqual(hr(foo), "<foo() at test_humanreadable.py:15>")
|
||||
self.failUnlessEqual(hr(self.test_repr),
|
||||
"<bound method HumanReadable.test_repr of <allmydata.test.test_humanreadable.HumanReadable testMethod=test_repr>>")
|
||||
self.failUnlessEqual(hr(long(1)), "1")
|
||||
@ -37,7 +42,9 @@ class HumanReadable(unittest.TestCase):
|
||||
except Exception as e:
|
||||
self.failUnless(
|
||||
hr(e) == "<ValueError: 'oops'>" # python-2.4
|
||||
or hr(e) == "ValueError('oops',)") # python-2.5
|
||||
or hr(e) == "ValueError('oops',)" # python-2.5
|
||||
or hr(e) == "ValueError(u'oops',)" # python 2 during py3 transition
|
||||
)
|
||||
try:
|
||||
raise NoArgumentException
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user