Skip to content

Commit

Permalink
extract test utilities and other code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Sep 21, 2017
1 parent 7e6e6b4 commit 1836e51
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 44 deletions.
22 changes: 1 addition & 21 deletions quipucords/cli/auth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,11 @@
#
"""Test the CLI module"""

import contextlib
import unittest
import sys
import six
from cli.cli import CLI


# pylint: disable=too-few-public-methods
class HushUpStderr(object):
"""Class used to quiet standard error output"""
def write(self, stream):
"""Ignore standard error output"""
pass


@contextlib.contextmanager
def redirect_stdout(stream):
"""Run a code block, capturing stdout to the given stream"""

old_stdout = sys.stdout
try:
sys.stdout = stream
yield
finally:
sys.stdout = old_stdout
from cli.tests_utilities import HushUpStderr, redirect_stdout


class AuthCliTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion quipucords/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# pylint: disable=too-few-public-methods
class CLI(object):
"""Class responsible for displaying ussage or matching inputs
to the valid set of commands supported by rho.
to the valid set of commands supported by qpc.
"""
def __init__(self, name="cli", usage=None, shortdesc=None,
description=None):
Expand Down
22 changes: 1 addition & 21 deletions quipucords/cli/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,11 @@
#
"""Test the CLI module"""

import contextlib
import unittest
import sys
import six
from cli.cli import CLI


# pylint: disable=too-few-public-methods
class HushUpStderr(object):
"""Class used to quiet standard error output"""
def write(self, stream):
"""Ignore standard error output"""
pass


@contextlib.contextmanager
def redirect_stdout(stream):
"""Run a code block, capturing stdout to the given stream"""

old_stdout = sys.stdout
try:
sys.stdout = stream
yield
finally:
sys.stdout = old_stdout
from cli.tests_utilities import HushUpStderr, redirect_stdout


class CliTests(unittest.TestCase):
Expand Down
34 changes: 34 additions & 0 deletions quipucords/cli/tests_utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (c) 2017 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 3 (GPLv3). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
# along with this software; if not, see
# https://www.gnu.org/licenses/gpl-3.0.txt.
#
"""Test utilities for the CLI module"""

import contextlib
import sys


# pylint: disable=too-few-public-methods
class HushUpStderr(object):
"""Class used to quiet standard error output"""
def write(self, stream):
"""Ignore standard error output"""
pass


@contextlib.contextmanager
def redirect_stdout(stream):
"""Run a code block, capturing stdout to the given stream"""

old_stdout = sys.stdout
try:
sys.stdout = stream
yield
finally:
sys.stdout = old_stdout
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
packages=find_packages(exclude=["test*.py"]),
package_data={'': ['LICENSE']},
url='https://github.com/quipucords/quipucords',
# non-python scripts go here
scripts=[
'bin/qpc',
],
Expand Down

0 comments on commit 1836e51

Please sign in to comment.