Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
1409d8a9
Commit
1409d8a9
authored
6 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
Story
SW-300
: add classes to test the std output from python UnitTest
framework
parent
4b11832d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!89
Monitoring maintenance Epic branch merge
,
!1
Resolve OSB-13 "Monitoringmaintenance "
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
LCU/Maintenance/MDB_tools/test/CMakeLists.txt
+1
-0
1 addition, 0 deletions
LCU/Maintenance/MDB_tools/test/CMakeLists.txt
LCU/Maintenance/MDB_tools/test/output_testing.py
+53
-0
53 additions, 0 deletions
LCU/Maintenance/MDB_tools/test/output_testing.py
with
55 additions
and
0 deletions
.gitattributes
+
1
−
0
View file @
1409d8a9
...
@@ -1830,6 +1830,7 @@ LCU/Maintenance/MDB_tools/cli/probe_mdb.py -text
...
@@ -1830,6 +1830,7 @@ LCU/Maintenance/MDB_tools/cli/probe_mdb.py -text
LCU/Maintenance/MDB_tools/deploy.sh -text
LCU/Maintenance/MDB_tools/deploy.sh -text
LCU/Maintenance/MDB_tools/fabfile.py -text
LCU/Maintenance/MDB_tools/fabfile.py -text
LCU/Maintenance/MDB_tools/requirements.txt -text
LCU/Maintenance/MDB_tools/requirements.txt -text
LCU/Maintenance/MDB_tools/test/output_testing.py -text
LCU/Maintenance/MDB_tools/test/python-coverage.sh eol=lf
LCU/Maintenance/MDB_tools/test/python-coverage.sh eol=lf
LCU/Maintenance/MDB_tools/test/t_mdb_loader.in.test_rtsm.data -text
LCU/Maintenance/MDB_tools/test/t_mdb_loader.in.test_rtsm.data -text
LCU/Maintenance/MDB_tools/test/t_mdb_loader.in.test_stationtest.data -text
LCU/Maintenance/MDB_tools/test/t_mdb_loader.in.test_stationtest.data -text
...
...
This diff is collapsed.
Click to expand it.
LCU/Maintenance/MDB_tools/test/CMakeLists.txt
+
1
−
0
View file @
1409d8a9
...
@@ -7,3 +7,4 @@ file(COPY
...
@@ -7,3 +7,4 @@ file(COPY
lofar_add_test
(
t_mdb_loader
)
lofar_add_test
(
t_mdb_loader
)
lofar_add_test
(
t_probe_mdb
)
lofar_add_test
(
t_probe_mdb
)
This diff is collapsed.
Click to expand it.
LCU/Maintenance/MDB_tools/test/output_testing.py
0 → 100644
+
53
−
0
View file @
1409d8a9
# coding=utf-8
import
mock
try
:
from
StringIO
import
StringIO
except
ImportError
:
from
io
import
StringIO
class
compare_output_with
:
"""
This class purpose is to create a
'
with
'
environment to assert that the output is equal to the one specified
in the class constructor
"""
def
__init__
(
self
,
expected_stdout
):
"""
Class constructor takes a path to a text file that contains the expected std output
:param expected_stdout: expected standard output
:type expected_stdout: str
"""
self
.
expected_stdout
=
expected_stdout
def
__enter__
(
self
):
self
.
stdout_patcher
=
mock
.
patch
(
'
sys.stdout
'
,
new
=
StringIO
())
self
.
stdout_patcher
.
start
()
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
stdout_produced
=
self
.
stdout_patcher
.
target
.
stdout
.
getvalue
()
self
.
stdout_patcher
.
stop
()
assert
self
.
expected_stdout
==
stdout_produced
,
\
"
expected stdout {} differs from {}
"
.
format
(
repr
(
self
.
expected_stdout
),
repr
(
stdout_produced
))
class
compare_output_with_file_content
(
compare_output_with
):
"""
This class purpose is to create a
'
with
'
environment to assert that the output is equal to the one specified
in content of the file_path specified in the class constructor
"""
def
__init__
(
self
,
file_path
):
"""
Class constructor takes a path to a text file that contains the expected std output
:param file_path: path to the file containing the expected standard output
"""
try
:
with
open
(
file_path
,
'
r
'
)
as
fstream_in
:
content
=
fstream_in
.
read
()
except
IOError
as
e
:
raise
Exception
(
'
Cannot run test - IOError on file {}: {}
'
.
format
(
file_path
,
e
))
super
(
compare_output_with_file_content
,
self
).
__init__
(
content
)
\ No newline at end of file
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