Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11_abseil
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11_abseil
Commits
5f2e3baf
Commit
5f2e3baf
authored
Mar 30, 2022
by
Ralf W. Grosse-Kunstleve
Committed by
Copybara-Service
Mar 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Add .code_int() to register_status_bindings.cc
PiperOrigin-RevId: 438396511
parent
0807a71b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
pybind11_abseil/register_status_bindings.cc
+3
-0
pybind11_abseil/tests/status_test.py
+4
-2
No files found.
pybind11_abseil/register_status_bindings.cc
View file @
5f2e3baf
...
@@ -138,6 +138,9 @@ void RegisterStatusBindings(module m) {
...
@@ -138,6 +138,9 @@ void RegisterStatusBindings(module m) {
.
def
(
init
<
absl
::
StatusCode
,
std
::
string
>
())
.
def
(
init
<
absl
::
StatusCode
,
std
::
string
>
())
.
def
(
"ok"
,
&
absl
::
Status
::
ok
)
.
def
(
"ok"
,
&
absl
::
Status
::
ok
)
.
def
(
"code"
,
&
absl
::
Status
::
code
)
.
def
(
"code"
,
&
absl
::
Status
::
code
)
.
def
(
"code_int"
,
[](
const
absl
::
Status
&
self
)
{
return
static_cast
<
int
>
(
self
.
code
());
})
.
def
(
"message"
,
&
absl
::
Status
::
message
)
.
def
(
"message"
,
&
absl
::
Status
::
message
)
.
def
(
.
def
(
"update"
,
"update"
,
...
...
pybind11_abseil/tests/status_test.py
View file @
5f2e3baf
...
@@ -65,15 +65,17 @@ class StatusTest(absltest.TestCase):
...
@@ -65,15 +65,17 @@ class StatusTest(absltest.TestCase):
# The make_status function has been set up to return a status object
# The make_status function has been set up to return a status object
# instead of raising an exception (this is done in status_example.cc).
# instead of raising an exception (this is done in status_example.cc).
test_status
=
status_example
.
make_status
(
status
.
StatusCode
.
OK
)
test_status
=
status_example
.
make_status
(
status
.
StatusCode
.
OK
)
self
.
assertEqual
(
test_status
.
code
(),
status
.
StatusCode
.
OK
)
self
.
assertTrue
(
test_status
.
ok
())
self
.
assertTrue
(
test_status
.
ok
())
self
.
assertEqual
(
test_status
.
code
(),
status
.
StatusCode
.
OK
)
self
.
assertEqual
(
test_status
.
code_int
(),
0
)
def
test_make_not_ok
(
self
):
def
test_make_not_ok
(
self
):
# The make_status function should always return a status object, even if
# The make_status function should always return a status object, even if
# it is not ok (ie, it should *not* convert it to an exception).
# it is not ok (ie, it should *not* convert it to an exception).
test_status
=
status_example
.
make_status
(
status
.
StatusCode
.
CANCELLED
)
test_status
=
status_example
.
make_status
(
status
.
StatusCode
.
CANCELLED
)
self
.
assertEqual
(
test_status
.
code
(),
status
.
StatusCode
.
CANCELLED
)
self
.
assertFalse
(
test_status
.
ok
())
self
.
assertFalse
(
test_status
.
ok
())
self
.
assertEqual
(
test_status
.
code
(),
status
.
StatusCode
.
CANCELLED
)
self
.
assertEqual
(
test_status
.
code_int
(),
1
)
def
test_make_not_ok_manual_cast
(
self
):
def
test_make_not_ok_manual_cast
(
self
):
test_status
=
status_example
.
make_status_manual_cast
(
test_status
=
status_example
.
make_status_manual_cast
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment