Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lp_nn_robustness_verification
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
ludwig10_masters_thesis
lp_nn_robustness_verification
Commits
cfeea519
Verified
Commit
cfeea519
authored
2 years ago
by
Björn Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
test(examples): introduce tests for examples
parent
706a3ec6
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
tests/test_examples.py
+51
-0
51 additions, 0 deletions
tests/test_examples.py
with
51 additions
and
0 deletions
tests/test_examples.py
0 → 100644
+
51
−
0
View file @
cfeea519
import
os
from
glob
import
glob
from
itertools
import
chain
from
typing
import
Callable
,
Generator
import
pytest
from
lp_nn_robustness_verification.examples.solve_instances_in_parallel
import
(
solve_and_store_timed_solutions
,
)
from
lp_nn_robustness_verification.examples.solve_one_instance
import
optimize
@pytest.fixture
(
scope
=
"
module
"
)
def
file_deleter
()
->
Callable
[[
tuple
[
str
,
...]],
None
]:
def
deleter
(
endings
:
tuple
[
str
,
...])
->
None
:
for
file
in
chain
(
*
(
glob
(
f
"
*
{
ending
}
"
)
for
ending
in
endings
)
):
try
:
os
.
remove
(
file
)
except
FileNotFoundError
:
pass
return
deleter
@pytest.fixture
def
cleanup_txt_sol_and_cip_after_run
(
file_deleter
:
Callable
[[
tuple
[
str
,
...]],
None
]
)
->
Generator
[
None
,
None
,
None
]:
yield
file_deleter
((
"
*_timings.txt
"
,
"
.sol
"
,
"
.cip
"
))
@pytest.fixture
def
cleanup_txt_after_run
(
file_deleter
:
Callable
[[
tuple
[
str
,
...]],
None
]
)
->
Generator
[
None
,
None
,
None
]:
yield
file_deleter
((
"
*_timings.txt
"
,))
def
test_solve_and_store_timed_solutions
(
cleanup_txt_sol_and_cip_after_run
:
Generator
[
None
,
None
,
None
]
)
->
None
:
solve_and_store_timed_solutions
(
0
,
0
)
def
test_optimize
(
cleanup_txt_after_run
:
Generator
[
None
,
None
,
None
])
->
None
:
optimize
()
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