Skip to content

Commit e4cbca2

Browse files
committed
Address feedback
Signed-off-by: Marius Seritan <[email protected]>
1 parent d174ac2 commit e4cbca2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

mojo/stdlib/test/python/test_python_cpython.mojo

+13-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ from testing import assert_equal, assert_false, assert_raises, assert_true
2020

2121

2222
def test_PyObject_HasAttrString(mut python: Python):
23-
var Cpython_env = python.impl._cpython
23+
var cpython_env = python.impl.cpython()
2424

2525
var the_object = PythonObject(0)
26-
var result = Cpython_env[].PyObject_HasAttrString(
26+
var result = cpython_env.PyObject_HasAttrString(
2727
the_object.py_object, "__contains__"
2828
)
2929
assert_equal(0, result)
3030

3131
the_object = Python.list(1, 2, 3)
32-
result = Cpython_env[].PyObject_HasAttrString(
32+
result = cpython_env.PyObject_HasAttrString(
3333
the_object.py_object, "__contains__"
3434
)
3535
assert_equal(1, result)
@@ -48,19 +48,25 @@ def test_PyCapsule(mut python: Python):
4848
var result = cpython_env.PyCapsule_GetPointer(
4949
the_object.py_object, "some_name"
5050
)
51-
var expected = UnsafePointer[NoneType]()
52-
assert_equal(expected, result)
51+
var expected_none = UnsafePointer[NoneType]()
52+
assert_equal(expected_none, result)
5353

5454
# Build a capsule.
5555
var capsule_impl = UnsafePointer[UInt64].alloc(1)
56-
var capsule = Cpython_env[].PyCapsule_New(
56+
var capsule = cpython_env.PyCapsule_New(
5757
capsule_impl.bitcast[NoneType](), "some_name", destructor
5858
)
59-
var capsule_pointer = Cpython_env[].PyCapsule_GetPointer(
59+
var capsule_pointer = cpython_env.PyCapsule_GetPointer(
6060
capsule, "some_name"
6161
)
6262
assert_equal(capsule_impl.bitcast[NoneType](), capsule_pointer)
6363

64+
# Use a different name.
65+
result = cpython_env.PyCapsule_GetPointer(
66+
capsule, "some_other_name"
67+
)
68+
assert_equal(expected_none, result)
69+
6470

6571
def main():
6672
# initializing Python instance calls init_python

0 commit comments

Comments
 (0)