summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-01-01 19:27:32 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-01-01 19:27:32 (GMT)
commitde60401909fb6232159f8c3b14c50d108556caad (patch)
tree08594ee22b17a110aaef0c589abd813c0923d0b1 /Lib
parentd78735d8e32411a20fc31a78e705f4c067b4344f (diff)
downloadcpython-de60401909fb6232159f8c3b14c50d108556caad.zip
cpython-de60401909fb6232159f8c3b14c50d108556caad.tar.gz
cpython-de60401909fb6232159f8c3b14c50d108556caad.tar.bz2
Merged revisions 77218 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77218 | mark.dickinson | 2010-01-01 17:27:30 +0000 (Fri, 01 Jan 2010) | 5 lines Issue #5080: turn the DeprecationWarning from float arguments passed to integer PyArg_Parse* format codes into a TypeError. Add a DeprecationWarning for floats passed with the 'L' format code, which didn't previously have a warning. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_getargs2.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 108159c..a407788 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -1,16 +1,7 @@
import unittest
from test import support
from _testcapi import getargs_keywords
-
import warnings
-warnings.filterwarnings("ignore",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module=__name__)
-warnings.filterwarnings("ignore",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module="unittest")
"""
> How about the following counterproposal. This also changes some of
@@ -197,9 +188,24 @@ class Signed_TestCase(unittest.TestCase):
class LongLong_TestCase(unittest.TestCase):
def test_L(self):
from _testcapi import getargs_L
- # L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX)
+ # L returns 'long long', and does range checking (LLONG_MIN
+ # ... LLONG_MAX)
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ "ignore",
+ category=DeprecationWarning,
+ message=".*integer argument expected, got float",
+ module=__name__)
+ self.assertEqual(3, getargs_L(3.14))
+ with warnings.catch_warnings():
+ warnings.filterwarnings(
+ "error",
+ category=DeprecationWarning,
+ message=".*integer argument expected, got float",
+ module="unittest")
+ self.assertRaises(DeprecationWarning, getargs_L, 3.14)
+
self.assertRaises(TypeError, getargs_L, "Hello")
- self.assertEqual(3, getargs_L(3.14))
self.assertEqual(99, getargs_L(Int()))
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)