Ejemplo n.º 1
0
 def test_get_name(self):
     capsule = test_py3c.capsule_new()
     if CAPSULE_THUNK:
         self.assertEqual(test_py3c.capsule_getname(capsule), None)
     else:
         self.assertEqual(test_py3c.capsule_getname(capsule),
                          "test_capsule")
Ejemplo n.º 2
0
    def test_invalid_operations(self):
        capsule = "not a capsule"
        if CAPSULE_THUNK:
            error = TypeError
        else:
            error = ValueError
        self.assertRaises(error, test_py3c.capsule_getpointer_check, capsule)
        self.assertRaises(error, test_py3c.capsule_getdestructor_check,
                          capsule)
        self.assertRaises(error, test_py3c.capsule_getcontext, capsule)
        self.assertFalse(test_py3c.capsule_valid(capsule))

        if CAPSULE_THUNK:
            self.assertEqual(test_py3c.capsule_getname(capsule), None)
        else:
            self.assertRaises(error, test_py3c.capsule_getname, capsule)

        self.assertRaises(error, test_py3c.capsule_setpointer, capsule)
        self.assertRaises(error, test_py3c.capsule_setdestructor, capsule)
        self.assertRaises(error, test_py3c.capsule_setcontext, capsule, "")

        if CAPSULE_THUNK:
            self.assertRaises(NotImplementedError, test_py3c.capsule_setname,
                              capsule, "")
        else:
            self.assertRaises(error, test_py3c.capsule_setname, capsule, "")
Ejemplo n.º 3
0
 def test_setname(self):
     capsule = test_py3c.capsule_new()
     if CAPSULE_THUNK:
         self.assertRaises(NotImplementedError, test_py3c.capsule_setname, capsule, "other name")
     else:
         test_py3c.capsule_setname(capsule, "other name")
         self.assertEqual(test_py3c.capsule_getname(capsule), "other name")
Ejemplo n.º 4
0
 def test_setname(self):
     capsule = test_py3c.capsule_new()
     if CAPSULE_THUNK:
         self.assertRaises(NotImplementedError, test_py3c.capsule_setname,
                           capsule, "other name")
     else:
         test_py3c.capsule_setname(capsule, "other name")
         self.assertEqual(test_py3c.capsule_getname(capsule), "other name")
Ejemplo n.º 5
0
    def test_invalid_operations(self):
        capsule = "not a capsule"
        if CAPSULE_THUNK:
            error = TypeError
        else:
            error = ValueError
        self.assertRaises(error, test_py3c.capsule_getpointer_check, capsule)
        self.assertRaises(error, test_py3c.capsule_getdestructor_check, capsule)
        self.assertRaises(error, test_py3c.capsule_getcontext, capsule)
        self.assertFalse(test_py3c.capsule_valid(capsule))

        if CAPSULE_THUNK:
            self.assertEqual(test_py3c.capsule_getname(capsule), None)
        else:
            self.assertRaises(error, test_py3c.capsule_getname, capsule)

        self.assertRaises(error, test_py3c.capsule_setpointer, capsule)
        self.assertRaises(error, test_py3c.capsule_setdestructor, capsule)
        self.assertRaises(error, test_py3c.capsule_setcontext, capsule, "")

        if CAPSULE_THUNK:
            self.assertRaises(NotImplementedError, test_py3c.capsule_setname, capsule, "")
        else:
            self.assertRaises(error, test_py3c.capsule_setname, capsule, "")
Ejemplo n.º 6
0
 def test_get_name(self):
     capsule = test_py3c.capsule_new()
     if CAPSULE_THUNK:
         self.assertEqual(test_py3c.capsule_getname(capsule), None)
     else:
         self.assertEqual(test_py3c.capsule_getname(capsule), "test_capsule")