From 6fc41612c4dbbf7f9c0d7c521388a5561b5305b3 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Sun, 15 Mar 2020 10:53:00 +0100 Subject: [PATCH] Add unittest for debugprint --- test/test_main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/test_main.py diff --git a/test/test_main.py b/test/test_main.py new file mode 100644 index 0000000..ca74043 --- /dev/null +++ b/test/test_main.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + + +import unittest +import unittest.mock as mock +import sys + +sys.path.append('..') + +from check_http_json import debugPrint + + +class MainTest(unittest.TestCase): + """ + Tests for main + """ + + def test_debugprint(self): + with mock.patch('builtins.print') as mock_print: + debugPrint(True, 'debug') + mock_print.assert_called_once_with('debug') + + def test_debugprint_pprint(self): + with mock.patch('check_http_json.pprint') as mock_pprint: + debugPrint(True, 'debug', True) + mock_pprint.assert_called_once_with('debug')