From 3b161305003448f67e5f9c4847ff196e8d2ac716 Mon Sep 17 00:00:00 2001 From: ymdatta Date: Fri, 9 Nov 2018 08:39:47 +0530 Subject: [PATCH] test_option:Modify the tests to check support for optparse's types. --- tests/unit/test_option.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_option.py b/tests/unit/test_option.py index 7c90512..1cb9dae 100644 --- a/tests/unit/test_option.py +++ b/tests/unit/test_option.py @@ -23,12 +23,14 @@ def test_to_optparse(): assert optparse_opt.action == 'count' -def test_to_support_optparses_standard_types(): +@pytest.mark.parametrize('opttype,str_val,expected', [ + ('float', '2', 2.0), + ('complex', '2', (2+0j)), +]) +def test_to_support_optparses_standard_types(opttype, str_val, expected): """Show that optparse converts float and complex types correctly.""" - opt = manager.Option('-t', '--test') - - assert type(opt.normalize_from_setuptools(float(2))) == float - assert type(opt.normalize_from_setuptools(complex(2))) == complex + opt = manager.Option('-t', '--test', type=opttype) + assert opt.normalize_from_setuptools(str_val) == expected @mock.patch('optparse.Option')