def test_B(self):
     from _testcapi import getargs_B
     self.assertRaises(TypeError, getargs_B, 3.14)
     self.assertEqual(99, 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.assertEqual(0, getargs_B(BadInt3()))
     self.assertEqual(UCHAR_MAX, getargs_B(-1))
     self.assertEqual(0, getargs_B(0))
     self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
     self.assertEqual(0, getargs_B(UCHAR_MAX + 1))
     self.assertEqual(42, getargs_B(42))
     self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.assertRaises(TypeError, getargs_B, 3.14)
        self.assertEqual(99, getargs_B(Long()))
        self.assertEqual(99, getargs_B(Int()))

        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(0, getargs_B(0))
        self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.assertEqual(0, getargs_B(UCHAR_MAX+1))

        self.assertEqual(42, getargs_B(42))
        self.assertEqual(42, getargs_B(42))
        self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
Esempio n. 3
0
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.assertRaises(TypeError, getargs_B, 3.14)
        self.assertEqual(99, getargs_B(Long()))
        self.assertEqual(99, getargs_B(Int()))

        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(0, getargs_B(0))
        self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.assertEqual(0, getargs_B(UCHAR_MAX + 1))

        self.assertEqual(42, getargs_B(42))
        self.assertEqual(42, getargs_B(42))
        self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
Esempio n. 4
0
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.assertRaises(TypeError, getargs_B, 3.14)
        self.assertEqual(99, 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.assertEqual(0, getargs_B(BadInt3()))

        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(0, getargs_B(0))
        self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.assertEqual(0, getargs_B(UCHAR_MAX+1))

        self.assertEqual(42, getargs_B(42))
        self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.failUnlessEqual(3, getargs_B(3.14))
        self.failUnlessEqual(99, getargs_B(Long()))
        self.failUnlessEqual(99, getargs_B(Int()))

        self.failUnlessEqual(UCHAR_MAX, getargs_B(-1))
        self.failUnlessEqual(UCHAR_MAX, getargs_B(-1L))
        self.failUnlessEqual(0, getargs_B(0))
        self.failUnlessEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.failUnlessEqual(0, getargs_B(UCHAR_MAX + 1))

        self.failUnlessEqual(42, getargs_B(42))
        self.failUnlessEqual(42, getargs_B(42L))
        self.failUnlessEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
Esempio n. 6
0
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.failUnlessEqual(3, getargs_B(3.14))
        self.failUnlessEqual(99, getargs_B(Long()))
        self.failUnlessEqual(99, getargs_B(Int()))

        self.failUnlessEqual(UCHAR_MAX, getargs_B(-1))
        self.failUnlessEqual(UCHAR_MAX, getargs_B(-1L))
        self.failUnlessEqual(0, getargs_B(0))
        self.failUnlessEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.failUnlessEqual(0, getargs_B(UCHAR_MAX+1))

        self.failUnlessEqual(42, getargs_B(42))
        self.failUnlessEqual(42, getargs_B(42L))
        self.failUnlessEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
Esempio n. 7
0
    def test_B(self):
        from _testcapi import getargs_B
        # B returns 'unsigned char', no range checking
        self.assertRaises(TypeError, getargs_B, 3.14)
        self.assertEqual(99, getargs_B(Index()))
        self.assertEqual(0, getargs_B(IndexIntSubclass()))
        self.assertRaises(TypeError, getargs_B, BadIndex())
        with self.assertWarns(DeprecationWarning):
            self.assertEqual(1, getargs_B(BadIndex2()))
        self.assertEqual(0, getargs_B(BadIndex3()))
        self.assertRaises(TypeError, getargs_B, Int())
        self.assertEqual(0, getargs_B(IntSubclass()))
        self.assertRaises(TypeError, getargs_B, BadInt())
        self.assertRaises(TypeError, getargs_B, BadInt2())
        self.assertEqual(0, getargs_B(BadInt3()))

        self.assertEqual(UCHAR_MAX, getargs_B(-1))
        self.assertEqual(0, getargs_B(0))
        self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
        self.assertEqual(0, getargs_B(UCHAR_MAX+1))

        self.assertEqual(42, getargs_B(42))
        self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))