2017-03-18 08:41:59 -05:00
|
|
|
"""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:
|
2017-07-25 01:56:02 -05:00
|
|
|
assert len(m_sys.stderr.write.mock_calls) == 1
|
2017-03-18 08:41:59 -05:00
|
|
|
else:
|
2017-07-25 01:56:02 -05:00
|
|
|
assert len(file.write.mock_calls) == 1
|
2017-03-18 08:41:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
def test_prompt_help():
|
|
|
|
"""test method."""
|
|
|
|
file = mock.Mock()
|
|
|
|
import buku
|
|
|
|
buku.ExtendedArgumentParser.prompt_help(file)
|
2017-07-25 01:56:02 -05:00
|
|
|
assert len(file.write.mock_calls) == 1
|
2017-03-18 08:41:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
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)
|