Skip to content

Commit 4c697b9

Browse files
simplify tests
1 parent 146131a commit 4c697b9

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

tests/test_pytypes.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,11 @@ TEST_SUBMODULE(pytypes, m) {
320320
});
321321

322322
// See #2361
323-
// These four tests should reflect the text in `object.rst`, the
324-
// "Interaction with None" section.
325-
m.def("test_str_with_default_arg_none" ,[](py::str value) {
326-
return value;
327-
}, py::arg("value") = py::none());
328-
m.def("test_str_assign_none", []() {
323+
m.def("issue2361_str_implicit_copy_none", []() {
329324
py::str is_this_none = py::none();
330325
return is_this_none;
331326
});
332-
m.def("test_dict_with_default_arg_none", [](py::dict value) {
333-
return value;
334-
}, py::arg("value") = py::none());
335-
m.def("test_dict_assign_none", []() {
327+
m.def("issue2361_dict_implicit_copy_none", []() {
336328
py::dict is_this_none = py::none();
337329
return is_this_none;
338330
});

tests/test_pytypes.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,11 @@ def test_list_slicing():
281281
assert li[::2] == m.test_list_slicing(li)
282282

283283

284-
def test_pytypes_with_none():
284+
def test_issue2361():
285285
# See issue #2361
286-
assert m.test_str_assign_none() == "None"
286+
assert m.issue2361_str_implicit_copy_none() == "None"
287287
with pytest.raises(TypeError) as excinfo:
288-
m.test_str_with_default_arg_none()
289-
assert "incompatible function arguments" in str(excinfo.value)
290-
291-
with pytest.raises(TypeError) as excinfo:
292-
assert m.test_dict_assign_none()
293-
assert "'NoneType' object is not iterable" in str(excinfo.value)
294-
with pytest.raises(TypeError) as excinfo:
295-
m.test_dict_with_default_arg_none()
296-
assert "incompatible function arguments" in str(excinfo.value)
288+
assert m.issue2361_dict_implicit_copy_none()
297289

298290

299291
@pytest.mark.parametrize('method, args, fmt, expected_view', [

0 commit comments

Comments
 (0)