File: test_ExtendedArgumentParser.py

package info (click to toggle)
buku 4.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,076 kB
  • sloc: python: 6,305; sh: 92; makefile: 11
file content (39 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""test module."""
from itertools import product
from unittest import mock

import pytest


@pytest.mark.parametrize("platform, file", product(['win32', 'linux'], [None, mock.Mock()]))
def test_program_info(platform, file):
    """test method."""
    with mock.patch('buku.sys') as m_sys:
        import buku
        file = mock.Mock()
        if file is None:
            buku.ExtendedArgumentParser.program_info()
        else:
            buku.ExtendedArgumentParser.program_info(file)
        if platform == 'win32' and file == m_sys.stdout:
            assert len(m_sys.stderr.write.mock_calls) == 1
        else:
            assert len(file.write.mock_calls) == 1


def test_prompt_help():
    """test method."""
    file = mock.Mock()
    import buku
    buku.ExtendedArgumentParser.prompt_help(file)
    assert len(file.write.mock_calls) == 1


def test_print_help():
    """test method."""
    file = mock.Mock()
    import buku
    obj = buku.ExtendedArgumentParser()
    obj.program_info = mock.Mock()
    obj.print_help(file)
    obj.program_info.assert_called_once_with(file)