summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_numbers.py3
-rw-r--r--Lib/datetime.py51
-rw-r--r--Lib/test/clinic.test92
-rw-r--r--Lib/test/datetimetester.py46
-rw-r--r--Lib/test/test_getargs2.py48
-rw-r--r--Lib/test/test_grp.py4
-rw-r--r--Lib/test/test_int.py5
-rw-r--r--Lib/test/test_math.py15
-rwxr-xr-xLib/test/test_socket.py6
9 files changed, 60 insertions, 210 deletions
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index c6d843b..db500e8 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -134,8 +134,7 @@ class NumberTestCase(unittest.TestCase):
for t in signed_types + unsigned_types:
self.assertRaises(TypeError, t, 3.14)
self.assertRaises(TypeError, t, f)
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(t(d).value, 2)
+ self.assertRaises(TypeError, t, d)
self.assertEqual(t(i).value, 2)
def test_sizes(self):
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 952aebf..3090978 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -11,6 +11,7 @@ __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
import time as _time
import math as _math
import sys
+from operator import index as _index
def _cmp(x, y):
return 0 if x == y else 1 if x > y else -1
@@ -380,42 +381,10 @@ def _check_utc_offset(name, offset):
"-timedelta(hours=24) and timedelta(hours=24)" %
(name, offset))
-def _check_int_field(value):
- if isinstance(value, int):
- return value
- if isinstance(value, float):
- raise TypeError('integer argument expected, got float')
- try:
- value = value.__index__()
- except AttributeError:
- pass
- else:
- if not isinstance(value, int):
- raise TypeError('__index__ returned non-int (type %s)' %
- type(value).__name__)
- return value
- orig = value
- try:
- value = value.__int__()
- except AttributeError:
- pass
- else:
- if not isinstance(value, int):
- raise TypeError('__int__ returned non-int (type %s)' %
- type(value).__name__)
- import warnings
- warnings.warn("an integer is required (got type %s)" %
- type(orig).__name__,
- DeprecationWarning,
- stacklevel=2)
- return value
- raise TypeError('an integer is required (got type %s)' %
- type(value).__name__)
-
def _check_date_fields(year, month, day):
- year = _check_int_field(year)
- month = _check_int_field(month)
- day = _check_int_field(day)
+ year = _index(year)
+ month = _index(month)
+ day = _index(day)
if not MINYEAR <= year <= MAXYEAR:
raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), year)
if not 1 <= month <= 12:
@@ -426,10 +395,10 @@ def _check_date_fields(year, month, day):
return year, month, day
def _check_time_fields(hour, minute, second, microsecond, fold):
- hour = _check_int_field(hour)
- minute = _check_int_field(minute)
- second = _check_int_field(second)
- microsecond = _check_int_field(microsecond)
+ hour = _index(hour)
+ minute = _index(minute)
+ second = _index(second)
+ microsecond = _index(microsecond)
if not 0 <= hour <= 23:
raise ValueError('hour must be in 0..23', hour)
if not 0 <= minute <= 59:
@@ -2539,10 +2508,10 @@ else:
# Clean up unused names
del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH, _DI100Y, _DI400Y,
_DI4Y, _EPOCH, _MAXORDINAL, _MONTHNAMES, _build_struct_time,
- _check_date_fields, _check_int_field, _check_time_fields,
+ _check_date_fields, _check_time_fields,
_check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror,
_date_class, _days_before_month, _days_before_year, _days_in_month,
- _format_time, _format_offset, _is_leap, _isoweek1monday, _math,
+ _format_time, _format_offset, _index, _is_leap, _isoweek1monday, _math,
_ord2ymd, _time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord,
_divide_and_round, _parse_isoformat_date, _parse_isoformat_time,
_parse_hh_mm_ss_ff, _IsoCalendarDate)
diff --git a/Lib/test/clinic.test b/Lib/test/clinic.test
index cb76c37..5e6f129 100644
--- a/Lib/test/clinic.test
+++ b/Lib/test/clinic.test
@@ -418,11 +418,6 @@ test_bool_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
c = _PyLong_AsInt(args[2]);
if (c == -1 && PyErr_Occurred()) {
goto exit;
@@ -436,7 +431,7 @@ exit:
static PyObject *
test_bool_converter_impl(PyObject *module, int a, int b, int c)
-/*[clinic end generated code: output=25f20963894256a1 input=939854fa9f248c60]*/
+/*[clinic end generated code: output=b5ec6409d942e0f9 input=939854fa9f248c60]*/
/*[clinic input]
@@ -729,11 +724,6 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
long ival = PyLong_AsLong(args[0]);
if (ival == -1 && PyErr_Occurred()) {
@@ -756,11 +746,6 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t
if (nargs < 2) {
goto skip_optional;
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
long ival = PyLong_AsLong(args[1]);
if (ival == -1 && PyErr_Occurred()) {
@@ -783,14 +768,9 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
- long ival = PyLong_AsUnsignedLongMask(args[2]);
- if (ival == -1 && PyErr_Occurred()) {
+ unsigned long ival = PyLong_AsUnsignedLongMask(args[2]);
+ if (ival == (unsigned long)-1 && PyErr_Occurred()) {
goto exit;
}
else {
@@ -807,7 +787,7 @@ exit:
static PyObject *
test_unsigned_char_converter_impl(PyObject *module, unsigned char a,
unsigned char b, unsigned char c)
-/*[clinic end generated code: output=ebf905c5c9414762 input=021414060993e289]*/
+/*[clinic end generated code: output=c0a6ab3144481466 input=021414060993e289]*/
/*[clinic input]
@@ -841,11 +821,6 @@ test_short_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
long ival = PyLong_AsLong(args[0]);
if (ival == -1 && PyErr_Occurred()) {
@@ -874,7 +849,7 @@ exit:
static PyObject *
test_short_converter_impl(PyObject *module, short a)
-/*[clinic end generated code: output=86fe1a1496a7ff20 input=6a8a7a509a498ff4]*/
+/*[clinic end generated code: output=3ccda4bd08b6e4b4 input=6a8a7a509a498ff4]*/
/*[clinic input]
@@ -925,11 +900,6 @@ test_unsigned_short_converter(PyObject *module, PyObject *const *args, Py_ssize_
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
c = (unsigned short)PyLong_AsUnsignedLongMask(args[2]);
if (c == (unsigned short)-1 && PyErr_Occurred()) {
goto exit;
@@ -944,7 +914,7 @@ exit:
static PyObject *
test_unsigned_short_converter_impl(PyObject *module, unsigned short a,
unsigned short b, unsigned short c)
-/*[clinic end generated code: output=3779fe104319e3ae input=cdfd8eff3d9176b4]*/
+/*[clinic end generated code: output=576b5ce48424f351 input=cdfd8eff3d9176b4]*/
/*[clinic input]
@@ -984,11 +954,6 @@ test_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
a = _PyLong_AsInt(args[0]);
if (a == -1 && PyErr_Occurred()) {
goto exit;
@@ -996,11 +961,6 @@ test_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 2) {
goto skip_optional;
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
b = _PyLong_AsInt(args[1]);
if (b == -1 && PyErr_Occurred()) {
goto exit;
@@ -1023,11 +983,6 @@ test_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 4) {
goto skip_optional;
}
- if (PyFloat_Check(args[3])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
d = _PyLong_AsInt(args[3]);
if (d == -1 && PyErr_Occurred()) {
goto exit;
@@ -1041,7 +996,7 @@ exit:
static PyObject *
test_int_converter_impl(PyObject *module, int a, int b, int c, myenum d)
-/*[clinic end generated code: output=10a2e48a34af5d7a input=d20541fc1ca0553e]*/
+/*[clinic end generated code: output=8a1a7b02ebe9eeac input=d20541fc1ca0553e]*/
/*[clinic input]
@@ -1092,11 +1047,6 @@ test_unsigned_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t
if (nargs < 3) {
goto skip_optional;
}
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
c = (unsigned int)PyLong_AsUnsignedLongMask(args[2]);
if (c == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
@@ -1111,7 +1061,7 @@ exit:
static PyObject *
test_unsigned_int_converter_impl(PyObject *module, unsigned int a,
unsigned int b, unsigned int c)
-/*[clinic end generated code: output=189176ce67c7d2e7 input=5533534828b62fc0]*/
+/*[clinic end generated code: output=4f53904bfa1a0250 input=5533534828b62fc0]*/
/*[clinic input]
@@ -1145,11 +1095,6 @@ test_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
a = PyLong_AsLong(args[0]);
if (a == -1 && PyErr_Occurred()) {
goto exit;
@@ -1163,7 +1108,7 @@ exit:
static PyObject *
test_long_converter_impl(PyObject *module, long a)
-/*[clinic end generated code: output=44cd8823f59d116b input=d2179e3c9cdcde89]*/
+/*[clinic end generated code: output=e5e7883fddcf4218 input=d2179e3c9cdcde89]*/
/*[clinic input]
@@ -1263,11 +1208,6 @@ test_long_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
a = PyLong_AsLongLong(args[0]);
if (a == -1 && PyErr_Occurred()) {
goto exit;
@@ -1281,7 +1221,7 @@ exit:
static PyObject *
test_long_long_converter_impl(PyObject *module, long long a)
-/*[clinic end generated code: output=7143b585d7e433e8 input=d5fc81577ff4dd02]*/
+/*[clinic end generated code: output=0488ac9e8c1d77bb input=d5fc81577ff4dd02]*/
/*[clinic input]
@@ -1390,11 +1330,6 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
@@ -1410,11 +1345,6 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
if (nargs < 2) {
goto skip_optional;
}
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
@@ -1443,7 +1373,7 @@ exit:
static PyObject *
test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b,
Py_ssize_t c)
-/*[clinic end generated code: output=a46d2aaf40c10398 input=3855f184bb3f299d]*/
+/*[clinic end generated code: output=ea781bb7169b3436 input=3855f184bb3f299d]*/
/*[clinic input]
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index a9741d6..520a51d 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -5107,43 +5107,21 @@ class Oddballs(unittest.TestCase):
def __int__(self):
return self.value
- for xx in [decimal.Decimal(10),
- decimal.Decimal('10.9'),
- Number(10)]:
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(datetime(10, 10, 10, 10, 10, 10, 10),
- datetime(xx, xx, xx, xx, xx, xx, xx))
-
- with self.assertRaisesRegex(TypeError, '^an integer is required '
- r'\(got type str\)$'):
- datetime(10, 10, '10')
-
- f10 = Number(10.9)
- with self.assertRaisesRegex(TypeError, '^__int__ returned non-int '
- r'\(type float\)$'):
- datetime(10, 10, f10)
-
class Float(float):
pass
- s10 = Float(10.9)
- with self.assertRaisesRegex(TypeError, '^integer argument expected, '
- 'got float$'):
- datetime(10, 10, s10)
- with self.assertRaises(TypeError):
- datetime(10., 10, 10)
- with self.assertRaises(TypeError):
- datetime(10, 10., 10)
- with self.assertRaises(TypeError):
- datetime(10, 10, 10.)
- with self.assertRaises(TypeError):
- datetime(10, 10, 10, 10.)
- with self.assertRaises(TypeError):
- datetime(10, 10, 10, 10, 10.)
- with self.assertRaises(TypeError):
- datetime(10, 10, 10, 10, 10, 10.)
- with self.assertRaises(TypeError):
- datetime(10, 10, 10, 10, 10, 10, 10.)
+ for xx in [10.0, Float(10.9),
+ decimal.Decimal(10), decimal.Decimal('10.9'),
+ Number(10), Number(10.9),
+ '10']:
+ self.assertRaises(TypeError, datetime, xx, 10, 10, 10, 10, 10, 10)
+ self.assertRaises(TypeError, datetime, 10, xx, 10, 10, 10, 10, 10)
+ self.assertRaises(TypeError, datetime, 10, 10, xx, 10, 10, 10, 10)
+ self.assertRaises(TypeError, datetime, 10, 10, 10, xx, 10, 10, 10)
+ self.assertRaises(TypeError, datetime, 10, 10, 10, 10, xx, 10, 10)
+ self.assertRaises(TypeError, datetime, 10, 10, 10, 10, 10, xx, 10)
+ self.assertRaises(TypeError, datetime, 10, 10, 10, 10, 10, 10, xx)
+
#############################################################################
# Local Time Disambiguation
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 1a73fa4..0dec5b1 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -161,12 +161,10 @@ class Unsigned_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_b(BadIndex2()))
self.assertEqual(0, getargs_b(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_b(Int()))
+ self.assertRaises(TypeError, getargs_b, Int())
self.assertEqual(0, getargs_b(IntSubclass()))
self.assertRaises(TypeError, getargs_b, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_b(BadInt2()))
+ self.assertRaises(TypeError, getargs_b, BadInt2())
self.assertEqual(0, getargs_b(BadInt3()))
self.assertRaises(OverflowError, getargs_b, -1)
@@ -187,12 +185,10 @@ class Unsigned_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_B(BadIndex2()))
self.assertEqual(0, getargs_B(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_B(Int()))
+ self.assertRaises(TypeError, getargs_B, Int())
self.assertEqual(0, getargs_B(IntSubclass()))
self.assertRaises(TypeError, getargs_B, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_B(BadInt2()))
+ self.assertRaises(TypeError, getargs_B, BadInt2())
self.assertEqual(0, getargs_B(BadInt3()))
self.assertEqual(UCHAR_MAX, getargs_B(-1))
@@ -213,12 +209,10 @@ class Unsigned_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_H(BadIndex2()))
self.assertEqual(0, getargs_H(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_H(Int()))
+ self.assertRaises(TypeError, getargs_H, Int())
self.assertEqual(0, getargs_H(IntSubclass()))
self.assertRaises(TypeError, getargs_H, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_H(BadInt2()))
+ self.assertRaises(TypeError, getargs_H, BadInt2())
self.assertEqual(0, getargs_H(BadInt3()))
self.assertEqual(USHRT_MAX, getargs_H(-1))
@@ -240,12 +234,10 @@ class Unsigned_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_I(BadIndex2()))
self.assertEqual(0, getargs_I(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_I(Int()))
+ self.assertRaises(TypeError, getargs_I, Int())
self.assertEqual(0, getargs_I(IntSubclass()))
self.assertRaises(TypeError, getargs_I, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_I(BadInt2()))
+ self.assertRaises(TypeError, getargs_I, BadInt2())
self.assertEqual(0, getargs_I(BadInt3()))
self.assertEqual(UINT_MAX, getargs_I(-1))
@@ -293,12 +285,10 @@ class Signed_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_h(BadIndex2()))
self.assertEqual(0, getargs_h(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_h(Int()))
+ self.assertRaises(TypeError, getargs_h, Int())
self.assertEqual(0, getargs_h(IntSubclass()))
self.assertRaises(TypeError, getargs_h, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_h(BadInt2()))
+ self.assertRaises(TypeError, getargs_h, BadInt2())
self.assertEqual(0, getargs_h(BadInt3()))
self.assertRaises(OverflowError, getargs_h, SHRT_MIN-1)
@@ -319,12 +309,10 @@ class Signed_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_i(BadIndex2()))
self.assertEqual(0, getargs_i(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_i(Int()))
+ self.assertRaises(TypeError, getargs_i, Int())
self.assertEqual(0, getargs_i(IntSubclass()))
self.assertRaises(TypeError, getargs_i, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_i(BadInt2()))
+ self.assertRaises(TypeError, getargs_i, BadInt2())
self.assertEqual(0, getargs_i(BadInt3()))
self.assertRaises(OverflowError, getargs_i, INT_MIN-1)
@@ -345,12 +333,10 @@ class Signed_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_l(BadIndex2()))
self.assertEqual(0, getargs_l(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_l(Int()))
+ self.assertRaises(TypeError, getargs_l, Int())
self.assertEqual(0, getargs_l(IntSubclass()))
self.assertRaises(TypeError, getargs_l, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_l(BadInt2()))
+ self.assertRaises(TypeError, getargs_l, BadInt2())
self.assertEqual(0, getargs_l(BadInt3()))
self.assertRaises(OverflowError, getargs_l, LONG_MIN-1)
@@ -400,12 +386,10 @@ class LongLong_TestCase(unittest.TestCase):
with self.assertWarns(DeprecationWarning):
self.assertEqual(1, getargs_L(BadIndex2()))
self.assertEqual(0, getargs_L(BadIndex3()))
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(99, getargs_L(Int()))
+ self.assertRaises(TypeError, getargs_L, Int())
self.assertEqual(0, getargs_L(IntSubclass()))
self.assertRaises(TypeError, getargs_L, BadInt())
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(1, getargs_L(BadInt2()))
+ self.assertRaises(TypeError, getargs_L, BadInt2())
self.assertEqual(0, getargs_L(BadInt3()))
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index e511947..0993f09 100644
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -100,8 +100,8 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.skipTest('no groups')
# Choose an existent gid.
gid = entries[0][2]
- self.assertWarns(DeprecationWarning, grp.getgrgid, float(gid))
- self.assertWarns(DeprecationWarning, grp.getgrgid, str(gid))
+ self.assertRaises(TypeError, grp.getgrgid, float(gid))
+ self.assertRaises(TypeError, grp.getgrgid, str(gid))
if __name__ == "__main__":
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index 6fdf52e..d6be64e 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -517,10 +517,7 @@ class IntTestCases(unittest.TestCase):
self.assertIs(type(n), int)
bad_int = TruncReturnsBadInt()
- with self.assertWarns(DeprecationWarning):
- n = int(bad_int)
- self.assertEqual(n, 1)
- self.assertIs(type(n), int)
+ self.assertRaises(TypeError, int, bad_int)
good_int = TruncReturnsIntSubclass()
n = int(good_int)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 4b848a5..e06b1e6 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -502,14 +502,10 @@ class MathTests(unittest.TestCase):
self.assertRaises(ValueError, math.factorial, -10**100)
def testFactorialNonIntegers(self):
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(math.factorial(5.0), 120)
- with self.assertWarns(DeprecationWarning):
- self.assertRaises(ValueError, math.factorial, 5.2)
- with self.assertWarns(DeprecationWarning):
- self.assertRaises(ValueError, math.factorial, -1.0)
- with self.assertWarns(DeprecationWarning):
- self.assertRaises(ValueError, math.factorial, -1e100)
+ self.assertRaises(TypeError, math.factorial, 5.0)
+ self.assertRaises(TypeError, math.factorial, 5.2)
+ self.assertRaises(TypeError, math.factorial, -1.0)
+ self.assertRaises(TypeError, math.factorial, -1e100)
self.assertRaises(TypeError, math.factorial, decimal.Decimal('5'))
self.assertRaises(TypeError, math.factorial, decimal.Decimal('5.2'))
self.assertRaises(TypeError, math.factorial, "5")
@@ -520,8 +516,7 @@ class MathTests(unittest.TestCase):
# Currently raises OverflowError for inputs that are too large
# to fit into a C long.
self.assertRaises(OverflowError, math.factorial, 10**100)
- with self.assertWarns(DeprecationWarning):
- self.assertRaises(OverflowError, math.factorial, 1e100)
+ self.assertRaises(TypeError, math.factorial, 1e100)
def testFloor(self):
self.assertRaises(TypeError, math.floor)
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index aefba4f..dc13307 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -917,10 +917,8 @@ class GeneralModuleTests(unittest.TestCase):
self.assertIn('not NoneType', str(cm.exception))
with self.assertRaises(TypeError) as cm:
s.sendto(b'foo', 'bar', sockname)
- self.assertIn('an integer is required', str(cm.exception))
with self.assertRaises(TypeError) as cm:
s.sendto(b'foo', None, None)
- self.assertIn('an integer is required', str(cm.exception))
# wrong number of args
with self.assertRaises(TypeError) as cm:
s.sendto(b'foo')
@@ -1899,11 +1897,11 @@ class GeneralModuleTests(unittest.TestCase):
socket.SOCK_STREAM)
def test_socket_fileno_rejects_float(self):
- with self.assertRaisesRegex(TypeError, "integer argument expected"):
+ with self.assertRaises(TypeError):
socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=42.5)
def test_socket_fileno_rejects_other_types(self):
- with self.assertRaisesRegex(TypeError, "integer is required"):
+ with self.assertRaises(TypeError):
socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno="foo")
def test_socket_fileno_rejects_invalid_socket(self):