Add automated CI for analyzers

This commit is contained in:
Jason Ertel
2022-03-29 13:10:04 -04:00
parent c23b87965f
commit 0a8d24a225
6 changed files with 63 additions and 7 deletions
@@ -0,0 +1,8 @@
[pytest]
python_files = *_test.py
python_classes = Test
python_functions = test_*
[report]
exclude_lines =
if __name__ == .__main__.:
@@ -1,5 +0,0 @@
def main():
print '{"foo":"bar","summary":"something here"}'
if __name__ == "__main__":
main()
@@ -1,5 +1,5 @@
def main():
print '{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}'
print('{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}')
if __name__ == "__main__":
main()
@@ -0,0 +1,12 @@
from io import StringIO
from unittest.mock import patch
from whois import whois
import unittest
class TestWhoisMethods(unittest.TestCase):
def test_main(self):
with patch('sys.stdout', new = StringIO()) as mock_stdout:
whois.main()
expected = '{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}\n'
self.assertEqual(mock_stdout.getvalue(), expected)