Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
6db878e8
L
labelme
项目概览
不会修仙的道士
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
labelme
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6db878e8
编写于
4月 02, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test for labelme/app.py
上级
14890e2c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
92 addition
and
8 deletion
+92
-8
labelme/__init__.py
labelme/__init__.py
+1
-0
labelme/testing.py
labelme/testing.py
+25
-0
tests/test_app.py
tests/test_app.py
+58
-0
tests/test_labelDialog.py
tests/test_labelDialog.py
+8
-8
未找到文件。
labelme/__init__.py
浏览文件 @
6db878e8
# flake8: noqa
from
labelme
import
testing
from
labelme
import
utils
labelme/testing.py
0 → 100644
浏览文件 @
6db878e8
import
json
import
os.path
as
osp
import
labelme.utils
def
assert_labelfile_sanity
(
filename
):
assert
osp
.
exists
(
filename
)
data
=
json
.
load
(
open
(
filename
))
assert
'imagePath'
in
data
imageData
=
data
.
get
(
'imageData'
,
None
)
if
imageData
is
None
:
assert
osp
.
exists
(
data
[
'imagePath'
])
img
=
labelme
.
utils
.
img_b64_to_arr
(
imageData
)
H
,
W
=
img
.
shape
[:
2
]
assert
'shapes'
in
data
for
shape
in
data
[
'shapes'
]:
assert
'label'
in
shape
assert
'points'
in
shape
for
x
,
y
in
shape
[
'points'
]:
assert
0
<=
x
<=
W
assert
0
<=
y
<=
H
tests/test_app.py
0 → 100644
浏览文件 @
6db878e8
import
os.path
as
osp
import
shutil
import
tempfile
import
labelme.app
import
labelme.testing
here
=
osp
.
dirname
(
osp
.
abspath
(
__file__
))
data_dir
=
osp
.
join
(
here
,
'data'
)
def
test_MainWindow_open
(
qtbot
):
win
=
labelme
.
app
.
MainWindow
()
qtbot
.
addWidget
(
win
)
win
.
show
()
win
.
close
()
def
test_MainWindow_open_json
(
qtbot
):
filename
=
osp
.
join
(
data_dir
,
'apc2016_obj3.json'
)
labelme
.
testing
.
assert_labelfile_sanity
(
filename
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
filename
)
qtbot
.
addWidget
(
win
)
win
.
show
()
win
.
close
()
def
test_MainWindow_annotate_jpg
(
qtbot
):
tmp_dir
=
tempfile
.
mkdtemp
()
filename
=
osp
.
join
(
tmp_dir
,
'apc2016_obj3.jpg'
)
shutil
.
copy
(
osp
.
join
(
data_dir
,
'apc2016_obj3.jpg'
),
filename
)
output
=
osp
.
join
(
tmp_dir
,
'apc2016_obj3.json'
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
filename
,
output
=
output
)
qtbot
.
addWidget
(
win
)
win
.
show
()
def
check_imageData
():
assert
hasattr
(
win
,
'imageData'
)
assert
win
.
imageData
is
not
None
qtbot
.
waitUntil
(
check_imageData
)
# wait for loadFile
label
=
'shelf'
points
=
[
(
26
,
70
),
(
176
,
730
),
(
986
,
742
),
(
1184
,
102
),
]
shape
=
label
,
points
,
None
,
None
shapes
=
[
shape
]
win
.
loadLabels
(
shapes
)
win
.
saveFile
()
labelme
.
testing
.
assert_labelfile_sanity
(
output
)
tests/test_labelDialog.py
浏览文件 @
6db878e8
...
...
@@ -57,9 +57,9 @@ def test_LabelDialog_popUp(qtbot):
# popUp(text='cat')
def
interact
():
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_P
)
# enter 'p' for 'person'
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_P
)
# enter 'p' for 'person'
# NOQA
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
QtCore
.
QTimer
.
singleShot
(
500
,
interact
)
text
=
widget
.
popUp
(
'cat'
)
...
...
@@ -68,8 +68,8 @@ def test_LabelDialog_popUp(qtbot):
# popUp()
def
interact
():
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
QtCore
.
QTimer
.
singleShot
(
500
,
interact
)
text
=
widget
.
popUp
()
...
...
@@ -78,9 +78,9 @@ def test_LabelDialog_popUp(qtbot):
# popUp() + key_Up
def
interact
():
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Up
)
# 'person' -> 'dog'
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Up
)
# 'person' -> 'dog'
# NOQA
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
qtbot
.
keyClick
(
widget
.
edit
,
QtCore
.
Qt
.
Key_Enter
)
# NOQA
QtCore
.
QTimer
.
singleShot
(
500
,
interact
)
text
=
widget
.
popUp
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录