Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.fusion.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.fusion.base
Commits
43186bae
Commit
43186bae
authored
4 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
[test_scripts] print stack trace when a test fails
parent
37e1af7f
No related branches found
No related tags found
No related merge requests found
Pipeline
#49232
passed
4 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/fusion/base/test/test_scripts.py
+12
-18
12 additions, 18 deletions
bob/fusion/base/test/test_scripts.py
with
12 additions
and
18 deletions
bob/fusion/base/test/test_scripts.py
+
12
−
18
View file @
43186bae
#!/usr/bin/env python
import
os
import
shutil
import
tempfile
import
numpy
from
nose.tools
import
assert_raises
from
..script.fuse
import
fuse
from
..script.boundary
import
boundary
from
bob.io.base.test_utils
import
datafile
from
bob.bio.base.score
import
load_score
from
click.testing
import
CliRunner
from
bob.extension.scripts.click_helper
import
assert_click_runner_result
train_files
=
[
datafile
(
"
scores-train-1
"
,
'
bob.fusion.base
'
,
'
test/data
'
),
datafile
(
"
scores-train-2
"
,
'
bob.fusion.base
'
,
'
test/data
'
)]
...
...
@@ -35,10 +33,6 @@ def compare_scores(path1, path2):
assert
all
(
score1
[
name
]
==
score2
[
name
])
def
click_result
(
result
):
return
"
%s, %s, %s
"
%
(
result
.
exit_code
,
result
.
output
,
result
.
exception
)
def
test_fuse
():
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
...
...
@@ -49,7 +43,7 @@ def test_fuse():
cmd
=
[
x
for
xy
in
zip
(
train_files
,
eval_files
)
for
x
in
xy
]
+
\
[
'
-g
'
,
'
train
'
,
'
-g
'
,
'
eval
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
compare_scores
(
fused_train_file
,
fused_train_files
[
0
])
compare_scores
(
fused_train_file
+
'
-licit
'
,
fused_train_files
[
1
])
compare_scores
(
fused_train_file
+
'
-spoof
'
,
fused_train_files
[
2
])
...
...
@@ -61,7 +55,7 @@ def test_fuse():
cmd
=
eval_files
+
[
'
-g
'
,
'
eval
'
,
'
-a
'
,
'
llr
'
,
'
-m
'
,
'
fusion_result/Model.pkl
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
compare_scores
(
fused_train_file
,
fused_train_files
[
0
])
compare_scores
(
fused_train_file
+
'
-licit
'
,
fused_train_files
[
1
])
compare_scores
(
fused_train_file
+
'
-spoof
'
,
fused_train_files
[
2
])
...
...
@@ -77,7 +71,7 @@ def test_fuse_train_only():
cmd
=
train_files
+
\
[
'
-g
'
,
'
train
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
compare_scores
(
fused_train_file
,
fused_train_files
[
0
])
compare_scores
(
fused_train_file
+
'
-licit
'
,
fused_train_files
[
1
])
compare_scores
(
fused_train_file
+
'
-spoof
'
,
fused_train_files
[
2
])
...
...
@@ -89,7 +83,7 @@ def test_fuse_with_dev():
cmd
=
train_files
+
train_files
+
\
[
'
-g
'
,
'
train
'
,
'
-g
'
,
'
dev
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
def
test_fuse_inconsistent
():
...
...
@@ -107,7 +101,7 @@ def test_fuse_inconsistent():
cmd
=
train_files
[
0
:
1
]
+
[
wrong_train2
]
+
\
[
'
-g
'
,
'
train
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
abs
(
result
.
exit_code
)
==
1
,
result
.
exit_code
assert
_click_runner_result
(
result
,
exit_code
=
1
)
assert
isinstance
(
result
.
exception
,
ValueError
)
# make inconsistency
...
...
@@ -122,7 +116,7 @@ def test_fuse_inconsistent():
cmd
=
train_files
[
0
:
1
]
+
[
wrong_train2
]
+
\
[
'
-g
'
,
'
train
'
,
'
-a
'
,
'
llr
'
,
'
--skip-check
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
assert
not
result
.
exception
,
result
.
exception
...
...
@@ -132,12 +126,12 @@ def test_boundary():
cmd
=
train_files
+
\
[
'
-g
'
,
'
train
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
model_file
=
'
fusion_result/Model.pkl
'
cmd
=
eval_files
+
[
'
-m
'
,
model_file
,
'
-t
'
,
'
0
'
]
result
=
runner
.
invoke
(
boundary
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
def
test_boundary_grouping
():
...
...
@@ -146,15 +140,15 @@ def test_boundary_grouping():
cmd
=
train_files
+
\
[
'
-g
'
,
'
train
'
,
'
-a
'
,
'
llr
'
]
result
=
runner
.
invoke
(
fuse
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
model_file
=
'
fusion_result/Model.pkl
'
cmd1
=
eval_files
+
[
'
-m
'
,
model_file
,
'
-t
'
,
'
0
'
]
cmd
=
cmd1
+
[
'
-G
'
,
'
random
'
,
'
-g
'
,
'
50
'
]
result
=
runner
.
invoke
(
boundary
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
cmd
=
cmd1
+
[
'
-G
'
,
'
kmeans
'
,
'
-g
'
,
'
50
'
]
result
=
runner
.
invoke
(
boundary
,
cmd
)
assert
result
.
exit_code
==
0
,
click
_result
(
result
)
assert
_click_runner
_result
(
result
)
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