Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TypedCols
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Warden
TypedCols
Commits
3b85355d
Commit
3b85355d
authored
Oct 24, 2017
by
Pavel Kácha
Browse files
Options
Downloads
Patches
Plain Diff
Fixed regression on unknown keys
parent
08f602f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
test_typedcols.py
+6
-4
6 additions, 4 deletions
test_typedcols.py
typedcols.py
+2
-2
2 additions, 2 deletions
typedcols.py
with
8 additions
and
6 deletions
test_typedcols.py
+
6
−
4
View file @
3b85355d
...
...
@@ -42,7 +42,8 @@ person_init_data = {
"
address
"
:
{
"
street
"
:
"
Vrchlikova
"
,
"
num
"
:
12.3
,
"
city
"
:
"
Kocourkov
"
"
city
"
:
"
Kocourkov
"
,
"
unknown
"
:
"
blah
"
},
"
discard1
"
:
"
junk
"
,
"
discard2
"
:
"
garbage
"
,
...
...
@@ -76,7 +77,8 @@ class TestTypedDict(unittest.TestCase):
"
address
"
:
{
"
street
"
:
"
Vrchlikova
"
,
"
num
"
:
12
,
"
city
"
:
"
Kocourkov
"
}})
"
city
"
:
"
Kocourkov
"
,
"
unknown
"
:
"
blah
"
}})
def
testSetGetKnownOk
(
self
):
self
.
person
[
"
address
"
][
"
city
"
]
=
"
Brno
"
...
...
@@ -126,7 +128,7 @@ class TestTypedDict(unittest.TestCase):
it
=
self
.
person
.
items
()
res
=
sorted
([
v
for
v
in
it
])
self
.
assertEqual
(
res
,
[
(
"
address
"
,
{
"
city
"
:
"
Kocourkov
"
,
"
street
"
:
"
Vrchlikova
"
,
"
num
"
:
12
}),
(
"
address
"
,
{
"
city
"
:
"
Kocourkov
"
,
"
street
"
:
"
Vrchlikova
"
,
"
num
"
:
12
,
"
unknown
"
:
"
blah
"
}),
(
"
age
"
,
34
),
(
"
name
"
,
"
_Default_Value_
"
),
(
"
note
"
,
None
)
...
...
@@ -136,7 +138,7 @@ class TestTypedDict(unittest.TestCase):
class
TestOpenTypedDict
(
TestTypedDict
):
def
setUp
(
self
):
open_address_dict
=
OpenTypedDict
(
typedef
=
address_typedef
.
copy
())
open_address_dict
=
OpenTypedDict
(
typedef
=
address_typedef
.
copy
()
,
allow_unknown
=
True
)
open_person_typedef
=
person_typedef
.
copy
()
open_person_typedef
[
"
address
"
]
=
open_address_dict
...
...
This diff is collapsed.
Click to expand it.
typedcols.py
+
2
−
2
View file @
3b85355d
...
...
@@ -10,7 +10,7 @@ Defines TypedDict and TypedList, which enforce inserted types based on simple
type definition.
"""
__version__
=
'
0.1.1
0
'
__version__
=
'
0.1.1
1
'
__author__
=
'
Pavel Kácha <pavel.kacha@cesnet.cz>
'
import
collections
...
...
@@ -130,7 +130,7 @@ class TypedDictBase(collections.MutableMapping):
If key is not defined and allow_unknown is True, empty
definition is returned, otherwise KeyNotAllowed gets raised.
"""
tdef
=
{}
tdef
=
{
"
type
"
:
Any
}
try
:
tdef
=
self
.
typedef
[
key
]
except
KeyError
:
...
...
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