Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
TOPFARM
TopFarm2
Commits
620ab0ac
Commit
620ab0ac
authored
6 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
changed test_try_me to pytest
parent
afdad44b
No related branches found
No related tags found
1 merge request
!94
Handle disabled mpi
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_try_me.py
+21
-30
21 additions, 30 deletions
tests/test_try_me.py
topfarm/_topfarm.py
+0
-1
0 additions, 1 deletion
topfarm/_topfarm.py
with
21 additions
and
31 deletions
tests/test_try_me.py
+
21
−
30
View file @
620ab0ac
'''
Created on 17. maj 2018
@author: mmpe
'''
import
unittest
import
topfarm
import
pkgutil
import
importlib
import
importlib
import
inspect
import
os
import
ast
import
pkgutil
import
warnings
import
warnings
from
topfarm.cost_models.fuga
import
lib_reader
import
mock
import
mock
import
pytest
import
pytest
import
os
import
topfarm
class
TestTryMe
(
unittest
.
TestCase
):
def
get_try_me_modules
():
def
test_try_me
(
self
):
package
=
topfarm
if
os
.
name
==
'
posix
'
and
"
DISPLAY
"
not
in
os
.
environ
:
modules
=
[]
pytest
.
xfail
(
"
No display
"
)
for
_
,
modname
,
_
in
pkgutil
.
walk_packages
(
package
.
__path__
,
package
.
__name__
+
'
.
'
):
package
=
topfarm
with
warnings
.
catch_warnings
():
for
_
,
modname
,
_
in
pkgutil
.
walk_packages
(
package
.
__path__
,
package
.
__name__
+
'
.
'
):
warnings
.
simplefilter
(
"
ignore
"
)
with
warnings
.
catch_warnings
():
m
=
importlib
.
import_module
(
modname
)
warnings
.
simplefilter
(
"
ignore
"
)
if
'
try_me
'
in
dir
(
m
):
m
=
importlib
.
import_module
(
modname
)
modules
.
append
(
m
)
if
'
try_me
'
in
dir
(
m
):
return
modules
print
(
"
Checking %s.try_me
"
%
modname
)
with
mock
.
patch
.
object
(
m
,
"
__name__
"
,
"
__main__
"
):
getattr
(
m
,
'
try_me
'
)()
if
__name__
==
"
__main__
"
:
@pytest.mark.parametrize
(
"
module
"
,
get_try_me_modules
())
#import sys;sys.argv = ['', 'Test.testName']
def
test_try_me
(
module
):
unittest
.
main
()
# check that all try_me module examples run without errors
if
os
.
name
==
'
posix
'
and
"
DISPLAY
"
not
in
os
.
environ
:
pytest
.
xfail
(
"
No display
"
)
print
(
"
Checking %s.try_me
"
%
module
.
__name__
)
with
mock
.
patch
.
object
(
module
,
"
__name__
"
,
"
__main__
"
):
getattr
(
module
,
'
try_me
'
)()
This diff is collapsed.
Click to expand it.
topfarm/_topfarm.py
+
0
−
1
View file @
620ab0ac
import
time
import
time
import
numpy
as
np
import
numpy
as
np
import
warnings
import
warnings
from
wetb.utils.timing
import
print_time
with
warnings
.
catch_warnings
():
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'
ignore
'
,
FutureWarning
)
warnings
.
simplefilter
(
'
ignore
'
,
FutureWarning
)
from
openmdao.api
import
Problem
,
ScipyOptimizeDriver
,
IndepVarComp
from
openmdao.api
import
Problem
,
ScipyOptimizeDriver
,
IndepVarComp
...
...
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