forked from pybind/pybind11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patching in snapshot of PR pybind#4319
- Loading branch information
Ralf W. Grosse-Kunstleve
committed
Nov 9, 2022
1 parent
3163ae2
commit 5aa6093
Showing
7 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "pybind11_tests.h" | ||
|
||
namespace { | ||
struct any_struct {}; | ||
} // namespace | ||
|
||
TEST_SUBMODULE(unnamed_namespace_a, m) { | ||
if (py::detail::get_type_info(typeid(any_struct)) == nullptr) { | ||
py::class_<any_struct>(m, "unnamed_namespace_a_any_struct"); | ||
} else { | ||
m.attr("unnamed_namespace_a_any_struct") = py::none(); | ||
} | ||
m.attr("defined___clang__") = | ||
#if defined(__clang__) | ||
true; | ||
#else | ||
false; | ||
#endif | ||
m.attr("defined__LIBCPP_VERSION") = | ||
#if defined(_LIBCPP_VERSION) | ||
true; | ||
#else | ||
false; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
|
||
from pybind11_tests import unnamed_namespace_a as m | ||
from pybind11_tests import unnamed_namespace_b as mb | ||
|
||
|
||
@pytest.mark.xfail( | ||
"m.defined___clang__ or m.defined__LIBCPP_VERSION", | ||
reason="Known issues: https://github.com/pybind/pybind11/pull/4319", | ||
strict=False, | ||
) | ||
def test_have_class_any_struct(): | ||
assert m.unnamed_namespace_a_any_struct is not None | ||
|
||
|
||
def test_have_at_least_one_class_any_struct(): | ||
assert ( | ||
m.unnamed_namespace_a_any_struct is not None | ||
or mb.unnamed_namespace_b_any_struct is not None | ||
) | ||
|
||
|
||
@pytest.mark.xfail( | ||
"m.defined___clang__ or m.defined__LIBCPP_VERSION", | ||
reason="Known issues: https://github.com/pybind/pybind11/pull/4319", | ||
strict=True, | ||
) | ||
def test_have_both_class_any_struct(): | ||
assert ( | ||
m.unnamed_namespace_a_any_struct is not None | ||
and mb.unnamed_namespace_b_any_struct is not None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "pybind11_tests.h" | ||
|
||
namespace { | ||
struct any_struct {}; | ||
} // namespace | ||
|
||
TEST_SUBMODULE(unnamed_namespace_b, m) { | ||
if (py::detail::get_type_info(typeid(any_struct)) == nullptr) { | ||
py::class_<any_struct>(m, "unnamed_namespace_b_any_struct"); | ||
} else { | ||
m.attr("unnamed_namespace_b_any_struct") = py::none(); | ||
} | ||
m.attr("defined___clang__") = | ||
#if defined(__clang__) | ||
true; | ||
#else | ||
false; | ||
#endif | ||
m.attr("defined__LIBCPP_VERSION") = | ||
#if defined(_LIBCPP_VERSION) | ||
true; | ||
#else | ||
false; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
|
||
from pybind11_tests import unnamed_namespace_b as m | ||
|
||
|
||
@pytest.mark.xfail( | ||
"m.defined___clang__ or m.defined__LIBCPP_VERSION", | ||
reason="Known issues: https://github.com/pybind/pybind11/pull/4319", | ||
strict=False, | ||
) | ||
def test_have_class_any_struct(): | ||
assert m.unnamed_namespace_b_any_struct is not None |