Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

upgrade flake8-docstrings to 1.1.0 and fix coverage to pass travis #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def main():
"""Main function."""
"""Print some information about Golf cars."""
title = 'Jetta SportWagen'

# AsciiTable.
Expand Down
2 changes: 1 addition & 1 deletion example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def table_abcd():


def main():
"""Main function."""
"""Print some example tables to the console."""
Windows.enable(auto_colors=True, reset_atexit=True) # Does nothing if not on Windows.

# Server timings.
Expand Down
2 changes: 1 addition & 1 deletion example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def main():
"""Main function."""
"""Print a line-wrapped table of Lorem-ipsum sample text."""
table_data = [
['Long String', ''], # One row. Two columns. Long string will replace this empty string.
]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class CheckVersion(Command):

@classmethod
def initialize_options(cls):
"""Required by distutils."""
"""Provide default values for all options, required by distutils."""
pass

@classmethod
def finalize_options(cls):
"""Required by distutils."""
"""Decide on the final values for all options, required by distutils."""
pass

@classmethod
Expand Down
9 changes: 8 additions & 1 deletion tests/test_terminal_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
class MockKernel32(object):
"""Mock kernel32."""

def __init__(self, stderr=terminal_io.INVALID_HANDLE_VALUE, stdout=terminal_io.INVALID_HANDLE_VALUE):
def __init__(self,
stderr=terminal_io.INVALID_HANDLE_VALUE,
stdout=terminal_io.INVALID_HANDLE_VALUE,
screen_buffer_info=True):
"""Constructor."""
self.stderr = stderr
self.stdout = stdout
self.csbi_err = b'x\x00)#\x00\x00\x87\x05\x07\x00\x00\x00j\x05w\x00\x87\x05x\x00J\x00' # 119 x 29
self.csbi_out = b'L\x00,\x01\x00\x00*\x01\x07\x00\x00\x00\x0e\x01K\x00*\x01L\x00L\x00' # 75 x 28
self.setConsoleTitleA_called = False
self.setConsoleTitleW_called = False
self.screen_buffer_info = screen_buffer_info

def GetConsoleScreenBufferInfo(self, handle, lpcsbi): # noqa
"""Mock GetConsoleScreenBufferInfo.

:param handle: Unused handle.
:param lpcsbi: ctypes.create_string_buffer() return value.
"""
if not self.screen_buffer_info:
return 0

if handle == self.stderr:
lpcsbi.raw = self.csbi_err
else:
Expand Down
30 changes: 21 additions & 9 deletions tests/test_terminal_io/test_get_console_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,36 @@

import pytest

from terminaltables.terminal_io import get_console_info, INVALID_HANDLE_VALUE, IS_WINDOWS
from terminaltables.terminal_io import get_console_info, INVALID_HANDLE_VALUE

from tests.test_terminal_io import MockKernel32


def test():
"""Test function."""
# Test live WinError.
if IS_WINDOWS:
with pytest.raises(OSError):
get_console_info(ctypes.windll.kernel32, 0)
@pytest.mark.skipif("sys.platform != 'win32'")
def test_live_win_error():
"""Test live WinError."""
with pytest.raises(OSError):
get_console_info(ctypes.windll.kernel32, 0)


# Test INVALID_HANDLE_VALUE.
def test_invalid_handle_value():
"""Test INVALID_HANDLE_VALUE."""
kernel32 = MockKernel32(stderr=1)
with pytest.raises(OSError):
get_console_info(kernel32, INVALID_HANDLE_VALUE)

# Test no error with mock methods.

def test_no_error_with_mock_methods():
"""Test no error with mock methods."""
kernel32 = MockKernel32(stderr=1)
width, height = get_console_info(kernel32, 1)
assert width == 119
assert height == 29


@pytest.mark.skipif("sys.platform != 'win32'")
def test_no_console_screen_buffer_info():
"""Test no console screen buffer info."""
kernel32 = MockKernel32(stderr=1, screen_buffer_info=False)
with pytest.raises(OSError):
get_console_info(kernel32, 1)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ commands =
flake8 --application-import-names={[general]name},tests
pylint --rcfile=tox.ini setup.py {[general]name}
deps =
flake8-docstrings==1.0.3
flake8-docstrings==1.1.0
flake8-import-order==0.12
flake8==3.3.0
pep8-naming==0.4.1
Expand Down