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
109358d8
Commit
109358d8
authored
Feb 25, 2021
by
Charlie Beattie
Committed by
Copybara-Service
Feb 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal change
PiperOrigin-RevId: 359606102
parent
a2223619
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
pybind11_abseil/status_utils.cc
+2
-2
pybind11_abseil/tests/status_test.py
+19
-0
No files found.
pybind11_abseil/status_utils.cc
View file @
109358d8
...
@@ -104,8 +104,8 @@ void RegisterStatusBindings(module m) {
...
@@ -104,8 +104,8 @@ void RegisterStatusBindings(module m) {
"update"
,
"update"
,
(
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"
,
&
absl
::
Status
::
ToString
)
.
def
(
"to_string"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
}
)
.
def
(
"__repr__"
,
&
absl
::
Status
::
ToString
);
.
def
(
"__repr__"
,
[](
const
absl
::
Status
&
s
)
{
return
s
.
ToString
();
}
);
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 @
109358d8
...
@@ -92,6 +92,18 @@ class StatusTest(absltest.TestCase):
...
@@ -92,6 +92,18 @@ class StatusTest(absltest.TestCase):
failure_status
=
status_example
.
make_status
(
status
.
StatusCode
.
CANCELLED
)
failure_status
=
status_example
.
make_status
(
status
.
StatusCode
.
CANCELLED
)
self
.
assertFalse
(
status
.
is_ok
(
failure_status
))
self
.
assertFalse
(
status
.
is_ok
(
failure_status
))
def
test_ok_to_string
(
self
):
ok_status
=
status_example
.
make_status
(
status
.
StatusCode
.
OK
)
self
.
assertEqual
(
ok_status
.
to_string
(),
'OK'
)
self
.
assertEqual
(
repr
(
ok_status
),
'OK'
)
self
.
assertEqual
(
str
(
ok_status
),
'OK'
)
def
test_canonical_error_to_string
(
self
):
test_status
=
status
.
aborted_error
(
'test'
)
self
.
assertEqual
(
test_status
.
to_string
(),
'ABORTED: test'
)
self
.
assertEqual
(
repr
(
test_status
),
'ABORTED: test'
)
self
.
assertEqual
(
str
(
test_status
),
'ABORTED: test'
)
class
StatusOrTest
(
absltest
.
TestCase
):
class
StatusOrTest
(
absltest
.
TestCase
):
...
@@ -149,6 +161,13 @@ class StatusOrTest(absltest.TestCase):
...
@@ -149,6 +161,13 @@ class StatusOrTest(absltest.TestCase):
with
self
.
assertRaises
(
status
.
StatusNotOk
):
with
self
.
assertRaises
(
status
.
StatusNotOk
):
status_example
.
return_failure_status_or_pointer
()
status_example
.
return_failure_status_or_pointer
()
def
test_canonical_error_to_string
(
self
):
failure_result
=
status_example
.
make_failure_status_or
(
status
.
StatusCode
.
CANCELLED
)
self
.
assertEqual
(
failure_result
.
to_string
(),
'CANCELLED: '
)
self
.
assertEqual
(
repr
(
failure_result
),
'CANCELLED: '
)
self
.
assertEqual
(
str
(
failure_result
),
'CANCELLED: '
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
absltest
.
main
()
absltest
.
main
()
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