Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.

Address logger noise #15

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
7 changes: 7 additions & 0 deletions test_tox_pyenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def test_logs_if_no_pyenv_binary(self):
self.assertEqual(tox_pyenv.LOG.warning.call_args_list, expected_warn)


class TestToxPyenvLogger(unittest.TestCase):

def test_has_nullhandler(self):
handlers = {str(type(handler)) for handler in tox_pyenv.LOG.handlers}
self.assertTrue(any('NullHandler' in h for h in handlers))


class TestThings(unittest.TestCase):

def test_the_answer(self):
Expand Down
13 changes: 12 additions & 1 deletion tox_pyenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ def tox_get_python_executable(envconfig):

LOG = logging.getLogger(__name__)

try:
# Python 2.7+
NullHandler = logging.NullHandler
except AttributeError:
class NullHandler(logging.Handler):
"""This handler does nothing."""
def emit(self, record):
pass

LOG.addHandler(NullHandler())


class ToxPyenvException(Exception):

Expand All @@ -66,7 +77,7 @@ class PyenvWhichFailed(ToxPyenvException):


@tox_hookimpl
def tox_get_python_executable(envconfig):
def tox_get_python_executable(envconfig): # pylint: disable=R1710
"""Return a python executable for the given python base name.

The first plugin/hook which returns an executable path will determine it.
Expand Down