fix(tests): make omitted printer agent operations answer like a missing agent

This commit is contained in:
peachismomo
2026-09-23 00:35:33 +08:00
parent 9e34ca536b
commit be9ae6ffbf
@@ -264,8 +264,8 @@ public:
// request_bind_ticket returns its ticket through a std::string* out-param, which pybind11 // request_bind_ticket returns its ticket through a std::string* out-param, which pybind11
// cannot marshal back through a plain override. We dispatch manually: the Python plugin // cannot marshal back through a plain override. We dispatch manually: the Python plugin
// returns a (result, ticket) tuple, which we unpack into the int result and the out-param. // returns a (result, ticket) tuple, which we unpack into the int result and the out-param.
// Not required to be implemented, so a missing override falls back to the base default // Not required to be implemented, so a missing override answers with the same failure value
// instead of failing, mirroring what PYBIND11_OVERRIDE does for the other optional methods. // as the other printer-agent operations. Leave the out-param untouched on failure.
int request_bind_ticket(std::string* ticket) override int request_bind_ticket(std::string* ticket) override
{ {
try { try {
@@ -277,7 +277,7 @@ public:
pybind11::function override = pybind11::function override =
pybind11::get_override(static_cast<const PrinterAgentPluginCapability*>(this), "request_bind_ticket"); pybind11::get_override(static_cast<const PrinterAgentPluginCapability*>(this), "request_bind_ticket");
if (!override) if (!override)
return PrinterAgentPluginCapability::request_bind_ticket(ticket); return printer_agent_failure<int>();
try { try {
pybind11::tuple result = override().cast<pybind11::tuple>(); pybind11::tuple result = override().cast<pybind11::tuple>();
if (ticket) if (ticket)