Skip to content
Snippets Groups Projects
Commit d14f8419 authored by Destiny Kuehn's avatar Destiny Kuehn
Browse files

unittest

parent 767819a5
No related branches found
No related tags found
3 merge requests!17Unittest,!16Unittest,!15Unittest
Pipeline #1524 failed with stage
in 1 minute and 21 seconds
"""Tests for 'lopt' package."""
import socket
import unittest
from unittest.mock import patch
from lopt.lopt import getHostname, main
class Test_lopt(unittest.TestCase):
def test_import(self):
"""Tests lopt launch"""
with patch('sys.argv', ['lopt', '-h']):
with self.assertRaises(SystemExit) as cmd:
main()
self.assertEqual(cmd.exception.code, 0, "sys.exit(0) never called, failed to exercise lopt")
def test_get_host_name(self):
"""Tests that getHostname gets the correct hostname"""
lopt_name = getHostname()
test_name = socket.gethostname()
error_message = "The function getHostname did not retreive the correct hostname."
self.assertEqual(lopt_name, test_name, error_message)
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment