Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDEA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Warden
IDEA
Commits
8f8bde48
Commit
8f8bde48
authored
7 years ago
by
Jan Mach
Browse files
Options
Downloads
Patches
Plain Diff
Added sort_keys default to True into to_json method.
This is very usefull both for unit testing and for readability.
parent
dffa2a26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
idea/base.py
+1
-0
1 addition, 0 deletions
idea/base.py
test_idea.py
+2
-2
2 additions, 2 deletions
test_idea.py
with
3 additions
and
2 deletions
idea/base.py
+
1
−
0
View file @
8f8bde48
...
...
@@ -346,4 +346,5 @@ class IdeaBase(typedcols.TypedDict):
raise
ValueError
(
o
)
def
to_json
(
self
,
*
args
,
**
kwargs
):
kwargs
.
setdefault
(
'
sort_keys
'
,
True
)
return
json
.
dumps
(
self
,
default
=
self
.
json_default
,
*
args
,
**
kwargs
)
This diff is collapsed.
Click to expand it.
test_idea.py
+
2
−
2
View file @
8f8bde48
...
...
@@ -79,13 +79,13 @@ class TestIdea(unittest.TestCase):
def
testLiteIdea
(
self
):
idea
=
lite
.
Idea
(
raw_idea
)
orig
=
json
.
dumps
(
raw_idea
,
indent
=
4
,
sort_keys
=
True
)
new
=
idea
.
to_json
(
indent
=
4
,
sort_keys
=
True
)
new
=
idea
.
to_json
(
indent
=
4
)
self
.
assertEqual
(
orig
,
new
,
"
\n
"
.
join
([
l
for
l
in
difflib
.
context_diff
(
orig
.
split
(
"
\n
"
),
new
.
split
(
"
\n
"
))]))
def
testValidIdea
(
self
):
idea
=
valid
.
Idea
(
raw_idea
)
orig
=
json
.
dumps
(
raw_idea
,
indent
=
4
,
sort_keys
=
True
)
new
=
idea
.
to_json
(
indent
=
4
,
sort_keys
=
True
)
new
=
idea
.
to_json
(
indent
=
4
)
self
.
assertEqual
(
orig
,
new
,
"
\n
"
.
join
([
l
for
l
in
difflib
.
context_diff
(
orig
.
split
(
"
\n
"
),
new
.
split
(
"
\n
"
))]))
...
...
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