forked from go-python/cpy3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reflection_test.go
54 lines (38 loc) · 1.03 KB
/
reflection_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package python3
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestReflectionBuiltins(t *testing.T) {
Py_Initialize()
builtins := PyEval_GetBuiltins()
assert.NotNil(t, builtins)
len := PyDict_GetItemString(builtins, "len")
assert.True(t, PyCallable_Check(len))
}
func TestReflectionLocals(t *testing.T) {
Py_Initialize()
locals := PyEval_GetLocals()
assert.Nil(t, locals)
}
func TestReflectionGlobals(t *testing.T) {
Py_Initialize()
globals := PyEval_GetGlobals()
assert.Nil(t, globals)
}
func TestReflectionFuncName(t *testing.T) {
Py_Initialize()
builtins := PyEval_GetBuiltins()
assert.NotNil(t, builtins)
len := PyDict_GetItemString(builtins, "len")
assert.True(t, PyCallable_Check(len))
assert.Equal(t, "len", PyEval_GetFuncName(len))
}
func TestReflectionFuncDesc(t *testing.T) {
Py_Initialize()
builtins := PyEval_GetBuiltins()
assert.NotNil(t, builtins)
len := PyDict_GetItemString(builtins, "len")
assert.True(t, PyCallable_Check(len))
assert.Equal(t, "()", PyEval_GetFuncDesc(len))
}