Skip to content

Commit 7560a02

Browse files
authored
Merge pull request #56 from martinRenou/fix_test_warning
Fix deprecation warning in tests
2 parents 8a6e453 + a541857 commit 7560a02

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/test_pybind11_json.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* The full license is in the file LICENSE, distributed with this software. *
77
****************************************************************************/
88

9-
#include <iostream>
109
#include <string>
1110
#include <vector>
1211
#include <cmath>
@@ -23,6 +22,11 @@ namespace nl = nlohmann;
2322

2423
using namespace pybind11::literals;
2524

25+
inline py::module create_module(const std::string& module_name)
26+
{
27+
return py::module_::create_extension_module(module_name.c_str(), nullptr, new py::module_::module_def);
28+
}
29+
2630
TEST(nljson_serializers_tojson, none)
2731
{
2832
py::scoped_interpreter guard;
@@ -429,7 +433,7 @@ inline const nl::json& test_fromtojson(const nl::json& json)
429433
TEST(pybind11_caster_tojson, dict)
430434
{
431435
py::scoped_interpreter guard;
432-
py::module m("test");
436+
py::module m = create_module("test");
433437

434438
m.def("to_json", &test_fromtojson);
435439

@@ -445,7 +449,7 @@ TEST(pybind11_caster_tojson, dict)
445449
TEST(pybind11_caster_fromjson, dict)
446450
{
447451
py::scoped_interpreter guard;
448-
py::module m("test");
452+
py::module m = create_module("test");
449453

450454
m.def("from_json", &test_fromtojson);
451455

0 commit comments

Comments
 (0)