Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite and test runner added #13

Merged
merged 1 commit into from
Jun 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tests

To run all tests simply run the following command from the root directory:

```python
>>> python tests/run.py
```

23 changes: 23 additions & 0 deletions tests/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
import test_ga
import test_lm
import test_ps
import test_utilities


def all_suites():

suites = [
test_ga.suite(),
test_lm.suite(),
test_ps.suite(),
test_utilities.suite()
]

all_suites = unittest.TestSuite(suites)
return all_suites

if __name__ == '__main__':
runner = unittest.TextTestRunner()
test_suite = all_suites()
runner.run (test_suite)
8 changes: 8 additions & 0 deletions tests/test_ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,13 @@ def test_ga(self):
next_err = errors[i]
self.assertGreaterEqual(prev_err, next_err)


def suite():
suite = unittest.TestSuite()
suite.addTest(TestGA('test_ga'))

return suite


if __name__ == '__main__':
unittest.main()
8 changes: 8 additions & 0 deletions tests/test_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,13 @@ def test_lm(self):
self.lm.save_plots()
# TODO: Check if all plots are saved


def suite():
suite = unittest.TestSuite()
suite.addTest(TestLM('test_lm'))

return suite


if __name__ == '__main__':
unittest.main()
8 changes: 8 additions & 0 deletions tests/test_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,13 @@ def test_ps(self):
next_err = errors[i]
self.assertGreaterEqual(prev_err, next_err)


def suite():
suite = unittest.TestSuite()
suite.addTest(TestPS('test_ps'))

return suite


if __name__ == '__main__':
unittest.main()
11 changes: 9 additions & 2 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from modestpy.utilities.delete_logs import delete_logs


class TestDeleteLogs(unittest.TestCase):
class TestUtilities(unittest.TestCase):
def setUp(self):
# Temp directory
self.temp_dir = tempfile.mkdtemp()
Expand All @@ -24,7 +24,7 @@ def setUp(self):
def tearDown(self):
try:
os.remove(self.log_path)
except WindowsError as e:
except OSError as e:
pass # File already removed
os.rmdir(self.temp_dir)

Expand All @@ -34,5 +34,12 @@ def test_delete_logs(self):
self.assertEqual(len(content), 0)


def suite():
suite = unittest.TestSuite()
suite.addTest(TestUtilities('test_delete_logs'))

return suite


if __name__ == "__main__":
unittest.main()