def test_n(self): from _testcapi import getargs_n # n returns 'Py_ssize_t', and does range checking # (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX) self.assertRaises(TypeError, getargs_n, 3.14) self.assertRaises(TypeError, getargs_n, Int()) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1) self.assertEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN)) self.assertEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX)) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1) self.assertEqual(42, getargs_n(42)) self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
def test_n(self): from _testcapi import getargs_n self.assertRaises(TypeError, getargs_n, 3.14) self.assertRaises(TypeError, getargs_n, Int()) self.assertEqual(0, getargs_n(IntSubclass())) self.assertRaises(TypeError, getargs_n, BadInt()) self.assertRaises(TypeError, getargs_n, BadInt2()) self.assertEqual(0, getargs_n(BadInt3())) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN - 1) self.assertEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN)) self.assertEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX)) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX + 1) self.assertEqual(42, getargs_n(42)) self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
def test_n(self): from _testcapi import getargs_n # n returns 'Py_ssize_t', and does range checking # (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX) self.assertRaises(TypeError, getargs_n, 3.14) self.assertEqual(99, getargs_n(Index())) self.assertEqual(0, getargs_n(IndexIntSubclass())) self.assertRaises(TypeError, getargs_n, BadIndex()) with self.assertWarns(DeprecationWarning): self.assertEqual(1, getargs_n(BadIndex2())) self.assertEqual(0, getargs_n(BadIndex3())) self.assertRaises(TypeError, getargs_n, Int()) self.assertEqual(0, getargs_n(IntSubclass())) self.assertRaises(TypeError, getargs_n, BadInt()) self.assertRaises(TypeError, getargs_n, BadInt2()) self.assertEqual(0, getargs_n(BadInt3())) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1) self.assertEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN)) self.assertEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX)) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1) self.assertEqual(42, getargs_n(42)) self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
def test_n(self): from _testcapi import getargs_n # n returns 'Py_ssize_t', and does range checking # (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX) self.failUnlessEqual(3, getargs_n(3.14)) self.failUnlessEqual(99, getargs_n(Long())) self.failUnlessEqual(99, getargs_n(Int())) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1) self.failUnlessEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN)) self.failUnlessEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX)) self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1) self.failUnlessEqual(42, getargs_n(42)) self.failUnlessEqual(42, getargs_n(42L)) self.assertRaises(OverflowError, getargs_n, VERY_LARGE)