Skip to content
Closed
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
14 changes: 13 additions & 1 deletion tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
# setup.py that excludes installing the "tests" package

import unittest
from unittest.mock import patch
from io import StringIO

from sample.simple import add_one
from sample import main


class TestSimple(unittest.TestCase):

def test_add_one(self):
self.assertEqual(add_one(5), 6)

def test_main(self):
"""Проверяем, что функция main() печатает нужный текст"""
with patch('sys.stdout', new=StringIO()) as fake_out:
main()
self.assertEqual(
fake_out.getvalue().strip(),
"Call your main application code here"
)


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