Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python-cliff
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenStack
python
python-cliff
Commits
91c62985
Commit
91c62985
authored
2 years ago
by
Zuul
Committed by
Gerrit Code Review
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge "columns: Useful __str__, __repr__ implementation"
parents
d1b46e9f
67217b0e
No related branches found
Branches containing commit
Tags
4.1.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cliff/columns.py
+6
-0
6 additions, 0 deletions
cliff/columns.py
cliff/tests/test_columns.py
+17
-3
17 additions, 3 deletions
cliff/tests/test_columns.py
with
23 additions
and
3 deletions
cliff/columns.py
+
6
−
0
View file @
91c62985
...
...
@@ -31,6 +31,12 @@ class FormattableColumn(object, metaclass=abc.ABCMeta):
self
.
__class__
==
other
.
__class__
and
self
.
_value
<
other
.
_value
)
def
__str__
(
self
):
return
self
.
human_readable
()
def
__repr__
(
self
):
return
'
%s(%r)
'
%
(
self
.
__class__
.
__name__
,
self
.
machine_readable
())
@abc.abstractmethod
def
human_readable
(
self
):
"""
Return a basic human readable version of the data.
"""
...
...
This diff is collapsed.
Click to expand it.
cliff/tests/test_columns.py
+
17
−
3
View file @
91c62985
...
...
@@ -23,17 +23,31 @@ class FauxColumn(columns.FormattableColumn):
class
TestColumns
(
unittest
.
TestCase
):
def
test_
faux_column_machin
e
(
self
):
def
test_
machine_readabl
e
(
self
):
c
=
FauxColumn
([
'
list
'
,
'
of
'
,
'
values
'
])
self
.
assertEqual
([
'
list
'
,
'
of
'
,
'
values
'
],
c
.
machine_readable
())
def
test_
faux_col
umn_
human
(
self
):
def
test_
h
um
a
n_
readable
(
self
):
c
=
FauxColumn
([
'
list
'
,
'
of
'
,
'
values
'
])
self
.
assertEqual
(
u
"
I made this string myself: [
'
list
'
,
'
of
'
,
'
values
'
]
"
,
"
I made this string myself: [
'
list
'
,
'
of
'
,
'
values
'
]
"
,
c
.
human_readable
(),
)
def
test_str
(
self
):
c
=
FauxColumn
([
'
list
'
,
'
of
'
,
'
values
'
])
self
.
assertEqual
(
"
I made this string myself: [
'
list
'
,
'
of
'
,
'
values
'
]
"
,
str
(
c
),
)
def
test_repr
(
self
):
c
=
FauxColumn
([
'
list
'
,
'
of
'
,
'
values
'
])
self
.
assertEqual
(
"
FauxColumn([
'
list
'
,
'
of
'
,
'
values
'
])
"
,
repr
(
c
),
)
def
test_sorting
(
self
):
cols
=
[
FauxColumn
(
'
foo
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment