diff options
author | Doug Hellmann <doug.hellmann@dreamhost.com> | 2013-03-16 13:33:23 -0700 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@dreamhost.com> | 2013-03-16 13:33:23 -0700 |
commit | c3baaff098e3e43323fd77ccef7c4814f9de2cf5 (patch) | |
tree | efa839f489baed04fbd66e73da0facb65744f255 /tests/test_commandmanager.py | |
parent | 18f649c229e025e938241f5c2c15ead57d9d7c4d (diff) | |
download | cliff-c3baaff098e3e43323fd77ccef7c4814f9de2cf5.tar.gz |
Add tests for underscore handling
Add tests for the convert_underscores option
to CommandManager.
Change-Id: I5f91bb539bce69936ea86f7a370df2412c3a913c
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
Diffstat (limited to 'tests/test_commandmanager.py')
-rw-r--r-- | tests/test_commandmanager.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_commandmanager.py b/tests/test_commandmanager.py index 1945f2e..8924405 100644 --- a/tests/test_commandmanager.py +++ b/tests/test_commandmanager.py @@ -93,3 +93,27 @@ def test_load_commands(): assert iter_entry_points.called_once_with('test') names = [n for n, v in mgr] assert names == ['test'] + + +def test_load_commands_keep_underscores(): + testcmd = mock.Mock() + testcmd.name = 'test_cmd' + mock_pkg_resources = mock.Mock(return_value=[testcmd]) + with mock.patch('pkg_resources.iter_entry_points', + mock_pkg_resources) as iter_entry_points: + mgr = CommandManager('test', convert_underscores=False) + assert iter_entry_points.called_once_with('test') + names = [n for n, v in mgr] + assert names == ['test_cmd'] + + +def test_load_commands_replace_underscores(): + testcmd = mock.Mock() + testcmd.name = 'test_cmd' + mock_pkg_resources = mock.Mock(return_value=[testcmd]) + with mock.patch('pkg_resources.iter_entry_points', + mock_pkg_resources) as iter_entry_points: + mgr = CommandManager('test', convert_underscores=True) + assert iter_entry_points.called_once_with('test') + names = [n for n, v in mgr] + assert names == ['test cmd'] |