"Fossies" - the Fresh Open Source Software Archive

Member "buku-4.4/tests/test_ExtendedArgumentParser.py" (15 Jun 2020, 1089 Bytes) of package /linux/privat/buku-4.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 """test module."""
    2 from itertools import product
    3 from unittest import mock
    4 
    5 import pytest
    6 
    7 
    8 @pytest.mark.parametrize("platform, file", product(['win32', 'linux'], [None, mock.Mock()]))
    9 def test_program_info(platform, file):
   10     """test method."""
   11     with mock.patch('buku.sys') as m_sys:
   12         import buku
   13         file = mock.Mock()
   14         if file is None:
   15             buku.ExtendedArgumentParser.program_info()
   16         else:
   17             buku.ExtendedArgumentParser.program_info(file)
   18         if platform == 'win32' and file == m_sys.stdout:
   19             assert len(m_sys.stderr.write.mock_calls) == 1
   20         else:
   21             assert len(file.write.mock_calls) == 1
   22 
   23 
   24 def test_prompt_help():
   25     """test method."""
   26     file = mock.Mock()
   27     import buku
   28     buku.ExtendedArgumentParser.prompt_help(file)
   29     assert len(file.write.mock_calls) == 1
   30 
   31 
   32 def test_print_help():
   33     """test method."""
   34     file = mock.Mock()
   35     import buku
   36     obj = buku.ExtendedArgumentParser()
   37     obj.program_info = mock.Mock()
   38     obj.print_help(file)
   39     obj.program_info.assert_called_once_with(file)