Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
43ebfd9a
Commit
43ebfd9a
authored
Aug 27, 2018
by
Kai Chen
Browse files
move some unit tests
parent
d4c472cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
tests/test_io.py
tests/test_io.py
+22
-0
tests/test_path.py
tests/test_path.py
+0
-22
No files found.
tests/test_io.py
View file @
43ebfd9a
...
...
@@ -79,3 +79,25 @@ def test_exception():
with
pytest
.
raises
(
TypeError
):
mmcv
.
dump
(
test_obj
,
'tmp.txt'
)
def
test_list_from_file
():
filename
=
osp
.
join
(
osp
.
dirname
(
__file__
),
'data/filelist.txt'
)
filelist
=
mmcv
.
list_from_file
(
filename
)
assert
filelist
==
[
'1.jpg'
,
'2.jpg'
,
'3.jpg'
,
'4.jpg'
,
'5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
prefix
=
'a/'
)
assert
filelist
==
[
'a/1.jpg'
,
'a/2.jpg'
,
'a/3.jpg'
,
'a/4.jpg'
,
'a/5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
offset
=
2
)
assert
filelist
==
[
'3.jpg'
,
'4.jpg'
,
'5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
max_num
=
2
)
assert
filelist
==
[
'1.jpg'
,
'2.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
offset
=
3
,
max_num
=
3
)
assert
filelist
==
[
'4.jpg'
,
'5.jpg'
]
def
test_dict_from_file
():
filename
=
osp
.
join
(
osp
.
dirname
(
__file__
),
'data/mapping.txt'
)
mapping
=
mmcv
.
dict_from_file
(
filename
)
assert
mapping
==
{
'1'
:
'cat'
,
'2'
:
[
'dog'
,
'cow'
],
'3'
:
'panda'
}
mapping
=
mmcv
.
dict_from_file
(
filename
,
key_type
=
int
)
assert
mapping
==
{
1
:
'cat'
,
2
:
[
'dog'
,
'cow'
],
3
:
'panda'
}
tests/test_path.py
View file @
43ebfd9a
...
...
@@ -5,28 +5,6 @@ import mmcv
import
pytest
def
test_list_from_file
():
filename
=
osp
.
join
(
osp
.
dirname
(
__file__
),
'data/filelist.txt'
)
filelist
=
mmcv
.
list_from_file
(
filename
)
assert
filelist
==
[
'1.jpg'
,
'2.jpg'
,
'3.jpg'
,
'4.jpg'
,
'5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
prefix
=
'a/'
)
assert
filelist
==
[
'a/1.jpg'
,
'a/2.jpg'
,
'a/3.jpg'
,
'a/4.jpg'
,
'a/5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
offset
=
2
)
assert
filelist
==
[
'3.jpg'
,
'4.jpg'
,
'5.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
max_num
=
2
)
assert
filelist
==
[
'1.jpg'
,
'2.jpg'
]
filelist
=
mmcv
.
list_from_file
(
filename
,
offset
=
3
,
max_num
=
3
)
assert
filelist
==
[
'4.jpg'
,
'5.jpg'
]
def
test_dict_from_file
():
filename
=
osp
.
join
(
osp
.
dirname
(
__file__
),
'data/mapping.txt'
)
mapping
=
mmcv
.
dict_from_file
(
filename
)
assert
mapping
==
{
'1'
:
'cat'
,
'2'
:
[
'dog'
,
'cow'
],
'3'
:
'panda'
}
mapping
=
mmcv
.
dict_from_file
(
filename
,
key_type
=
int
)
assert
mapping
==
{
1
:
'cat'
,
2
:
[
'dog'
,
'cow'
],
3
:
'panda'
}
def
test_check_file_exist
():
mmcv
.
check_file_exist
(
__file__
)
if
sys
.
version_info
>
(
3
,
3
):
...
...
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