예제 #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")
예제 #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, "")
예제 #3
0
파일: __main__.py 프로젝트: eye3/py3c
 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")
예제 #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")
예제 #5
0
파일: __main__.py 프로젝트: eye3/py3c
    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, "")
예제 #6
0
파일: __main__.py 프로젝트: eye3/py3c
 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")