Skip to content

Commit

Permalink
Add tests for underscore handling
Browse files Browse the repository at this point in the history
Add tests for the convert_underscores option
to CommandManager.

Change-Id: I5f91bb539bce69936ea86f7a370df2412c3a913c
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
  • Loading branch information
Doug Hellmann committed Mar 16, 2013
1 parent 18f649c commit c3baaff
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_commandmanager.py
Expand Up @@ -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']

0 comments on commit c3baaff

Please sign in to comment.