Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Feb 15, 2024
1 parent 05ff1c9 commit 4a84264
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ jobs:
- name: Check code style
run: pycodestyle --max-line-length=120 --ignore=E402,W504,W605,E722 . --exclude=doc

- name: Test with nose
#run: nosetests test/unit/connectors/*.py test/unit/*.py test/functional/*.py -v --stop --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=IM,contextualization
run: python -m coverage run --source=. -m unittest discover -s test/unit -p '*.py'
- name: Unit tests
run: python -m coverage run --source=. -m unittest discover -v -s test/unit -p '*.py'

- name: Generate XML coverage report
run: python -m coverage xml
Expand Down
3 changes: 2 additions & 1 deletion monitoring/probeim.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TimeOutExcetion(Exception):
Expand Down
3 changes: 2 additions & 1 deletion test/functional/test_im.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestIM(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/integration/QuickTestIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class QuickTestIM(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/integration/TestIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestIM(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/integration/TestREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestIM(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/integration/TestREST_JSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestIM(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/AppDBIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestAppDBIS(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/SSH.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestSSH(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/Tosca.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestTosca(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/connectors/CloudConn.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ def tearDown(self):
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()
3 changes: 2 additions & 1 deletion test/unit/openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestOpenIDClient(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
def read_file_as_string(file_name):
tests_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(tests_path, file_name)
return open(abs_file_path, 'r').read()
with open(abs_file_path, 'r') as f:
return f.read()


class TestIM(unittest.TestCase):
Expand Down

0 comments on commit 4a84264

Please sign in to comment.