From a83895494b09846cbbc7a2420392f757fe8064e4 Mon Sep 17 00:00:00 2001 From: Dan Liberatori Date: Sun, 12 Aug 2018 20:34:20 +0900 Subject: [PATCH] Rename and add assertion to coverage only test --- tests/ext/test_ext_argparse.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/ext/test_ext_argparse.py b/tests/ext/test_ext_argparse.py index cad45eb6..463918a3 100644 --- a/tests/ext/test_ext_argparse.py +++ b/tests/ext/test_ext_argparse.py @@ -1,6 +1,7 @@ import sys from pytest import raises, skip +from unittest.mock import patch from argparse import ArgumentError from cement.core.foundation import TestApp from cement.ext.ext_argparse import ArgparseArgumentHandler @@ -581,8 +582,7 @@ def test_get_exposed_commands(): assert 'cmd2-two' in app.controller._get_exposed_commands() -def test_coverage(): - # coverage +def test_hide_help(): class MyController(ArgparseController): class Meta: label = 'base' @@ -591,5 +591,9 @@ def test_coverage(): def hidden(self): pass - with TestApp(handlers=[MyController]) as app: - app.run() + with patch('argparse._SubParsersAction.add_parser') as mock: + with TestApp(handlers=[MyController]) as app: + app.run() + # help='should not be visible' should not + # get sent to the parser if hide=True + mock.assert_called_once_with('hidden')