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
6a4bf933
Commit
6a4bf933
authored
Feb 15, 2022
by
Xiaofei Wang
Committed by
Copybara-Service
Feb 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal change
PiperOrigin-RevId: 428861197
parent
1d53beb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
+14
-1
pybind11_abseil/register_status_bindings.cc
+6
-1
pybind11_abseil/tests/status_test.py
+8
-0
No files found.
pybind11_abseil/register_status_bindings.cc
View file @
6a4bf933
...
@@ -144,7 +144,12 @@ void RegisterStatusBindings(module m) {
...
@@ -144,7 +144,12 @@ void RegisterStatusBindings(module m) {
(
void
(
absl
::
Status
::*
)(
const
absl
::
Status
&
))
&
absl
::
Status
::
Update
,
(
void
(
absl
::
Status
::*
)(
const
absl
::
Status
&
))
&
absl
::
Status
::
Update
,
arg
(
"other"
))
arg
(
"other"
))
.
def
(
"to_string"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
})
.
def
(
"to_string"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
})
.
def
(
"__repr__"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
});
.
def
(
"__repr__"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
})
.
def_static
(
"OkStatus"
,
DoNotThrowStatus
(
&
absl
::
OkStatus
))
.
def
(
"raw_code"
,
&
absl
::
Status
::
code
)
.
def
(
"CanonicalCode"
,
&
absl
::
Status
::
code
)
.
def
(
"error_message"
,
&
absl
::
Status
::
message
)
.
def
(
"IgnoreError"
,
&
absl
::
Status
::
IgnoreError
);
m
.
def
(
"is_ok"
,
&
IsOk
,
arg
(
"status_or"
),
m
.
def
(
"is_ok"
,
&
IsOk
,
arg
(
"status_or"
),
"Returns false only if passed a non-ok status; otherwise returns true. "
"Returns false only if passed a non-ok status; otherwise returns true. "
...
...
pybind11_abseil/tests/status_test.py
View file @
6a4bf933
...
@@ -126,6 +126,14 @@ class StatusTest(absltest.TestCase):
...
@@ -126,6 +126,14 @@ class StatusTest(absltest.TestCase):
self
.
assertEqual
(
repr
(
test_status
),
'ABORTED: test'
)
self
.
assertEqual
(
repr
(
test_status
),
'ABORTED: test'
)
self
.
assertEqual
(
str
(
test_status
),
'ABORTED: test'
)
self
.
assertEqual
(
str
(
test_status
),
'ABORTED: test'
)
def
test_create_ok_status
(
self
):
ok_status
=
status
.
Status
.
OkStatus
()
self
.
assertEqual
(
ok_status
.
to_string
(),
'OK'
)
self
.
assertEqual
(
ok_status
.
raw_code
(),
status
.
StatusCode
.
OK
)
self
.
assertEqual
(
ok_status
.
CanonicalCode
(),
status
.
StatusCode
.
OK
)
self
.
assertEqual
(
ok_status
.
error_message
(),
''
)
self
.
assertIsNone
(
ok_status
.
IgnoreError
())
class
IntGetter
(
status_example
.
IntGetter
):
class
IntGetter
(
status_example
.
IntGetter
):
...
...
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