Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flex Extract
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flexpart
Flex Extract
Commits
efa05d7d
Commit
efa05d7d
authored
6 years ago
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
added more testcases
parent
97e09f41
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/pythontest/.cache/v/cache/lastfailed
+1
-0
1 addition, 0 deletions
python/pythontest/.cache/v/cache/lastfailed
python/pythontest/TestTools.py
+46
-7
46 additions, 7 deletions
python/pythontest/TestTools.py
python/tools.py
+2
-3
2 additions, 3 deletions
python/tools.py
with
49 additions
and
10 deletions
python/pythontest/.cache/v/cache/lastfailed
+
1
−
0
View file @
efa05d7d
{
"TestTools.py": true,
"TestTools.py::TestTools::()::test_failany_silent_remove": true,
"TestTools.py::TestTools::test_init128": true,
"TestTools.py::TestTools::test_to_param_id": true
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
python/pythontest/TestTools.py
+
46
−
7
View file @
efa05d7d
...
...
@@ -6,12 +6,14 @@ import sys
import
subprocess
import
pipes
import
pytest
from
unittest.mock
import
patch
sys
.
path
.
append
(
'
../
'
)
import
_config
from
tools
import
(
init128
,
to_param_id
,
my_error
,
read_ecenv
,
get_cmdline_arguments
,
submit_job_to_ecserver
,
put_file_to_ecserver
)
from
tools
import
(
get_cmdline_arguments
,
read_ecenv
,
clean_up
,
my_error
,
normal_exit
,
product
,
silent_remove
,
init128
,
to_param_id
,
get_list_as_string
,
make_dir
,
put_file_to_ecserver
,
submit_job_to_ecserver
)
class
TestTools
():
...
...
@@ -107,14 +109,51 @@ class TestTools():
def
test_product
(
self
):
assert
True
def
test_silent_remove
(
self
):
assert
True
def
test_success_silent_remove
(
self
,
capfd
):
testfile
=
'
testfile.test
'
open
(
testfile
,
'
w
'
).
close
()
silent_remove
(
testfile
)
out
,
err
=
capfd
.
readouterr
()
assert
os
.
path
.
isfile
(
testfile
)
==
False
assert
out
==
''
def
test_failnotexist_silent_remove
(
self
,
capfd
):
testfile
=
'
testfile.test
'
silent_remove
(
testfile
)
out
,
err
=
capfd
.
readouterr
()
assert
os
.
path
.
isfile
(
testfile
)
==
False
assert
out
==
''
@patch
(
silent_remove
)
def
test_failany_silent_remove
(
self
,
mock_silent_remove
):
testfile
=
'
testfileany.test
'
mock_silent_remove
.
side_effect
=
OSError
with
pytest
.
raises
(
OSError
)
as
pytest_wrapped_e
:
silent_remove
(
testfile
)
#out, err = capfd.readouterr()
#assert os.path.isfile(testfile) == False
#assert out == ''
def
test_get_list_as_string
(
self
):
assert
True
def
test_make_dir
(
self
):
assert
True
def
test_warningexist_make_dir
(
self
,
capfd
):
testdir
=
'
TestData
'
make_dir
(
testdir
)
out
,
err
=
capfd
.
readouterr
()
assert
out
.
strip
()
==
'
WARNING: Directory {0} already exists!
'
.
format
(
testdir
)
def
test_failany_make_dir
(
self
):
testdir
=
'
/test
'
# force a permission denied error
with
pytest
.
raises
(
OSError
)
as
pytest_wrapped_e
:
make_dir
(
testdir
)
assert
pytest_wrapped_e
.
type
==
OSError
def
test_success_make_dir
(
self
):
testdir
=
'
testing_mkdir
'
make_dir
(
testdir
)
assert
os
.
path
.
exists
(
testdir
)
==
True
os
.
rmdir
(
testdir
)
def
test_fail_put_file_to_ecserver
(
self
):
ecuid
=
os
.
environ
[
'
ECUID
'
]
...
...
This diff is collapsed.
Click to expand it.
python/tools.py
+
2
−
3
View file @
efa05d7d
...
...
@@ -315,7 +315,7 @@ def product(*args, **kwds):
def
silent_remove
(
filename
):
'''
@Description:
If
"
filename
"
exists , it is removed
.
Remove file if it exists
.
The function does not fail if the file does not exist.
@Input:
...
...
@@ -328,7 +328,6 @@ def silent_remove(filename):
try
:
os
.
remove
(
filename
)
except
OSError
as
e
:
# this would be "except OSError, e:" before Python 2.6
if
e
.
errno
!=
errno
.
ENOENT
:
# errno.ENOENT = no such file or directory
raise
# re-raise exception if a different error occured
...
...
@@ -426,7 +425,7 @@ def make_dir(directory):
@Input:
directory: string
The directory path which should be created.
The directory
name including the
path which should be created.
@Return:
<nothing>
...
...
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