Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
368bcb3f
Commit
368bcb3f
authored
5 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-516
: removed test for obsolete convertStringValuesToBuffer. Added test for is_iterable
parent
0a7a4931
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCS/PyCommon/test/t_util.py
+19
-39
19 additions, 39 deletions
LCS/PyCommon/test/t_util.py
with
19 additions
and
39 deletions
LCS/PyCommon/test/t_util.py
+
19
−
39
View file @
368bcb3f
...
@@ -11,45 +11,25 @@ def tearDownModule():
...
@@ -11,45 +11,25 @@ def tearDownModule():
pass
pass
class
TestUtils
(
unittest
.
TestCase
):
class
TestUtils
(
unittest
.
TestCase
):
def
test_string_to_buffer_and_back
(
self
):
def
test_is_iterable
(
self
):
original
=
'
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
'
#list
self
.
assertTrue
(
is_iterable
([]))
d
=
{
'
test-key
'
:
original
}
self
.
assertTrue
(
is_iterable
([
1
,
2
,
3
]))
#print str(d)
self
.
assertTrue
(
isinstance
(
d
[
'
test-key
'
],
str
))
#dict
self
.
assertTrue
(
is_iterable
({}))
d2
=
convertStringValuesToBuffer
(
d
,
0
)
self
.
assertTrue
(
is_iterable
({
1
:
2
,
3
:
4
}))
print
(
d2
)
self
.
assertTrue
(
isinstance
(
d2
[
'
test-key
'
],
memoryview
))
#tuple
self
.
assertTrue
(
is_iterable
((
1
,
2
,
4
)))
d3
=
convertBufferValuesToString
(
d2
)
print
(
d3
)
#string
self
.
assertTrue
(
isinstance
(
d3
[
'
test-key
'
],
str
))
self
.
assertTrue
(
is_iterable
(
"
abc
"
))
self
.
assertEqual
(
original
,
d3
[
'
test-key
'
])
# non-iterale types
#try conversion again but only for long strings
self
.
assertFalse
(
is_iterable
(
1
))
d2
=
convertStringValuesToBuffer
(
d
,
10000
)
self
.
assertFalse
(
is_iterable
(
None
))
print
(
d2
)
#type should still be basestring (so no conversion happened)
self
.
assertTrue
(
isinstance
(
d2
[
'
test-key
'
],
str
))
d3
=
convertBufferValuesToString
(
d2
)
print
(
d3
)
#type should still be basestring (so no conversion back was needed)
self
.
assertTrue
(
isinstance
(
d3
[
'
test-key
'
],
str
))
self
.
assertEqual
(
original
,
d3
[
'
test-key
'
])
#try with nested dict
d4
=
{
'
outer
'
:
d
}
d2
=
convertStringValuesToBuffer
(
d4
,
0
)
print
(
d2
)
self
.
assertTrue
(
isinstance
(
d2
[
'
outer
'
][
'
test-key
'
],
memoryview
))
d3
=
convertBufferValuesToString
(
d2
)
print
(
d3
)
self
.
assertTrue
(
isinstance
(
d3
[
'
outer
'
][
'
test-key
'
],
str
))
self
.
assertEqual
(
original
,
d3
[
'
outer
'
][
'
test-key
'
])
def
main
(
argv
):
def
main
(
argv
):
unittest
.
main
()
unittest
.
main
()
...
...
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