diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-05-17 19:21:20 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-05-17 19:21:20 (GMT) |
commit | 79a922d6df18e0c0e508905aebc8f4fa28052aac (patch) | |
tree | 101822957ff56f5de4151af23c94caff7ba24f63 /Lib/test | |
parent | 6c90c9faaeb20447df2e880f871ce10a80d2ff27 (diff) | |
download | cpython-79a922d6df18e0c0e508905aebc8f4fa28052aac.zip cpython-79a922d6df18e0c0e508905aebc8f4fa28052aac.tar.gz cpython-79a922d6df18e0c0e508905aebc8f4fa28052aac.tar.bz2 |
add Py3k warnings to oct and hex. backport hex behavior (because it's not different)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_builtin.py | 4 | ||||
-rw-r--r-- | Lib/test/test_py3kwarn.py | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 15d80a3..4264a99 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -632,6 +632,10 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(hex(-16L), '-0x10L') self.assertRaises(TypeError, hex, {}) + class Spam(object): + def __index__(self): return 23 + self.assertEqual(hex(Spam()), "0x17") + def test_id(self): id(None) id(1) diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index 2c8f509..e6d38f2 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -123,6 +123,20 @@ class TestPy3KWarnings(unittest.TestCase): with catch_warning() as w: self.assertWarning(buffer('a'), w, expected) + def test_hex_and_oct(self): + class Spam(object): + def __hex__(self): return "0x17" + def __oct__(self): return "07" + + expected = 'In 3.x, oct() converts the result of __index__ to octal; ' \ + 'Use future_builtins.oct for this behavior. ' \ + 'Also, note the returned format is different.' + with catch_warning() as w: + self.assertWarning(oct(Spam()), w, expected) + expected = 'In 3.x, hex() converts the result of __index__ to hexidecimal.' + with catch_warning() as w: + self.assertWarning(hex(Spam()), w, expected) + class TestStdlibRemovals(unittest.TestCase): |