diff --git a/examples/scripts/python_api/testFixture.py b/examples/scripts/python_api/testFixture.py index 524994b5093..5be3afa6dcc 100755 --- a/examples/scripts/python_api/testFixture.py +++ b/examples/scripts/python_api/testFixture.py @@ -24,7 +24,7 @@ import os -from gz.common import set_verbosity +from gz.common5 import set_verbosity from gz.sim8 import TestFixture, World, world_entity from gz.math7 import Vector3d diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 2fa8ee7e91d..59c82b23bce 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -66,17 +66,22 @@ target_compile_definitions(${BINDINGS_MODULE_NAME} PRIVATE BINDINGS_MODULE_NAME=${BINDINGS_MODULE_NAME}) # TODO(ahcorde): Move this module to gz-common -pybind11_add_module(common MODULE + +set(GZ_COMMON_BINDINGS_MODULE_NAME "common${GZ_COMMON_VER}") +pybind11_add_module(${GZ_COMMON_BINDINGS_MODULE_NAME} MODULE src/gz/common/_gz_common_pybind11.cc src/gz/common/Console.cc ) -target_link_libraries(common PRIVATE +target_compile_definitions(${GZ_COMMON_BINDINGS_MODULE_NAME} PRIVATE + BINDINGS_MODULE_NAME=${GZ_COMMON_BINDINGS_MODULE_NAME}) + +target_link_libraries(${GZ_COMMON_BINDINGS_MODULE_NAME} PRIVATE gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER} ) configure_build_install_location(${BINDINGS_MODULE_NAME}) -configure_build_install_location(common) +configure_build_install_location(${GZ_COMMON_BINDINGS_MODULE_NAME}) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # Workaround for Clang and pybind11 on Focal diff --git a/python/src/gz/common/_gz_common_pybind11.cc b/python/src/gz/common/_gz_common_pybind11.cc index 194e4a11da0..79bea9d98c7 100644 --- a/python/src/gz/common/_gz_common_pybind11.cc +++ b/python/src/gz/common/_gz_common_pybind11.cc @@ -16,7 +16,7 @@ #include "Console.hh" -PYBIND11_MODULE(common, m) { +PYBIND11_MODULE(BINDINGS_MODULE_NAME, m) { m.doc() = "Gazebo Common Python Library."; m.def( diff --git a/python/src/gz/sim/TestFixture.cc b/python/src/gz/sim/TestFixture.cc index 991f1f6b149..826558fbf4e 100644 --- a/python/src/gz/sim/TestFixture.cc +++ b/python/src/gz/sim/TestFixture.cc @@ -34,6 +34,11 @@ defineSimTestFixture(pybind11::object module) { pybind11::class_> testFixture(module, "TestFixture"); + // Since this class starts with "Test", pytest thinks it's a test and emits a + // warning when it can't "collect" it. + // Silence the warning by setting `__test__=False`. + testFixture.attr("__test__") = false; + testFixture .def(pybind11::init()) .def( diff --git a/python/test/actor_TEST.py b/python/test/actor_TEST.py index 2471cf2a560..8a8f76f1d88 100755 --- a/python/test/actor_TEST.py +++ b/python/test/actor_TEST.py @@ -17,7 +17,7 @@ import datetime import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import (Actor, K_NULL_ENTITY, TestFixture, World, world_entity) from gz_test_deps.math import Pose3d diff --git a/python/test/gz_test_deps/common.py b/python/test/gz_test_deps/common.py new file mode 100644 index 00000000000..d28e66e5e50 --- /dev/null +++ b/python/test/gz_test_deps/common.py @@ -0,0 +1 @@ +from gz.common5 import * diff --git a/python/test/joint_TEST.py b/python/test/joint_TEST.py index 78e15b0dc1a..5b015156152 100755 --- a/python/test/joint_TEST.py +++ b/python/test/joint_TEST.py @@ -16,7 +16,7 @@ import os import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import (K_NULL_ENTITY, TestFixture, Joint, Model, World, world_entity) from gz_test_deps.math import Pose3d diff --git a/python/test/link_TEST.py b/python/test/link_TEST.py index 961afefa840..b4e91602f21 100755 --- a/python/test/link_TEST.py +++ b/python/test/link_TEST.py @@ -16,7 +16,7 @@ import os import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import K_NULL_ENTITY, TestFixture, Link, Model, World, world_entity from gz_test_deps.math import Matrix3d, Vector3d diff --git a/python/test/model_TEST.py b/python/test/model_TEST.py index 2bb74e22a5c..5a450c78482 100755 --- a/python/test/model_TEST.py +++ b/python/test/model_TEST.py @@ -16,7 +16,7 @@ import os import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import K_NULL_ENTITY, TestFixture, Model, World, world_entity class TestModel(unittest.TestCase): diff --git a/python/test/sensor_TEST.py b/python/test/sensor_TEST.py index 7c4c420bf6a..aba4c61ca96 100755 --- a/python/test/sensor_TEST.py +++ b/python/test/sensor_TEST.py @@ -16,7 +16,7 @@ import os import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import (K_NULL_ENTITY, TestFixture, Joint, Model, Sensor, World, world_entity) from gz_test_deps.math import Pose3d diff --git a/python/test/testFixture_TEST.py b/python/test/testFixture_TEST.py index 80ea6560ffe..18f549bb6fe 100755 --- a/python/test/testFixture_TEST.py +++ b/python/test/testFixture_TEST.py @@ -16,9 +16,9 @@ import os import unittest -from gz.common import set_verbosity -from gz.sim8 import TestFixture, World, world_entity -from gz.math7 import Vector3d +from gz_test_deps.common import set_verbosity +from gz_test_deps.sim import TestFixture, World, world_entity +from gz_test_deps.math import Vector3d post_iterations = 0 iterations = 0 diff --git a/python/test/world_TEST.py b/python/test/world_TEST.py index 7e7e7de5a66..d44d80b9f8e 100755 --- a/python/test/world_TEST.py +++ b/python/test/world_TEST.py @@ -16,7 +16,7 @@ import os import unittest -from gz.common import set_verbosity +from gz_test_deps.common import set_verbosity from gz_test_deps.sim import K_NULL_ENTITY, TestFixture, World, world_entity from gz_test_deps.math import SphericalCoordinates, Vector3d from gz_test_deps.sdformat import Atmosphere