Removing `// clang-format off` - `on` directives from test_pickling.cpp (#3738)

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-02-15 11:51:17 -08:00 committed by GitHub
parent 0986af6182
commit c14170a787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 15 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/*
tests/test_pickling.cpp -- pickle support
@ -11,8 +10,6 @@
#include "pybind11_tests.h"
// clang-format on
#include <memory>
#include <stdexcept>
#include <utility>
@ -63,8 +60,6 @@ void wrap(py::module m) {
} // namespace exercise_trampoline
// clang-format off
TEST_SUBMODULE(pickling, m) {
// test_roundtrip
class Pickleable {
@ -76,6 +71,7 @@ TEST_SUBMODULE(pickling, m) {
void setExtra2(int extra2) { m_extra2 = extra2; }
int extra1() const { return m_extra1; }
int extra2() const { return m_extra2; }
private:
std::string m_value;
int m_extra1 = 0;
@ -88,8 +84,7 @@ TEST_SUBMODULE(pickling, m) {
};
py::class_<Pickleable> pyPickleable(m, "Pickleable");
pyPickleable
.def(py::init<std::string>())
pyPickleable.def(py::init<std::string>())
.def("value", &Pickleable::value)
.def("extra1", &Pickleable::extra1)
.def("extra2", &Pickleable::extra2)
@ -147,7 +142,8 @@ TEST_SUBMODULE(pickling, m) {
using PickleableWithDict::PickleableWithDict;
};
py::class_<PickleableWithDict> pyPickleableWithDict(m, "PickleableWithDict", py::dynamic_attr());
py::class_<PickleableWithDict> pyPickleableWithDict(
m, "PickleableWithDict", py::dynamic_attr());
pyPickleableWithDict.def(py::init<std::string>())
.def_readwrite("value", &PickleableWithDict::value)
.def_readwrite("extra", &PickleableWithDict::extra)
@ -176,7 +172,8 @@ TEST_SUBMODULE(pickling, m) {
.def(py::init<std::string>())
.def(py::pickle(
[](const py::object &self) {
return py::make_tuple(self.attr("value"), self.attr("extra"), self.attr("__dict__"));
return py::make_tuple(
self.attr("value"), self.attr("extra"), self.attr("__dict__"));
},
[](const py::tuple &t) {
if (t.size() != 3) {