From 9e859c4f6436385d937bb96b949bc66cf6c18bab Mon Sep 17 00:00:00 2001 From: Anthony Truchet Date: Fri, 25 Oct 2013 17:30:46 +0200 Subject: [test] Fix broken unittest_configuration.py:ConfigurationTC.test_round_trip --- test/unittest_configuration.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/unittest_configuration.py b/test/unittest_configuration.py index c95f8a1..a8e3c0f 100644 --- a/test/unittest_configuration.py +++ b/test/unittest_configuration.py @@ -18,6 +18,7 @@ import tempfile import os from os.path import join, dirname, abspath +import re from cStringIO import StringIO from sys import version_info @@ -32,13 +33,13 @@ DATA = join(dirname(abspath(__file__)), 'data') OPTIONS = [('dothis', {'type':'yn', 'action': 'store', 'default': True, 'metavar': ''}), ('value', {'type': 'string', 'metavar': '', 'short': 'v'}), - ('multiple', {'type': 'csv', 'default': ('yop', 'yep'), + ('multiple', {'type': 'csv', 'default': ['yop', 'yep'], 'metavar': '', 'help': 'you can also document the option'}), ('number', {'type': 'int', 'default':2, 'metavar':'', 'help': 'boom'}), ('choice', {'type': 'choice', 'default':'yo', 'choices': ('yo', 'ye'), 'metavar':''}), - ('multiple-choice', {'type': 'multiple_choice', 'default':('yo', 'ye'), + ('multiple-choice', {'type': 'multiple_choice', 'default':['yo', 'ye'], 'choices': ('yo', 'ye', 'yu', 'yi', 'ya'), 'metavar':''}), ('named', {'type':'named', 'default':Method('get_named'), @@ -63,10 +64,10 @@ class ConfigurationTC(TestCase): cfg = self.cfg self.assertEqual(cfg['dothis'], True) self.assertEqual(cfg['value'], None) - self.assertEqual(cfg['multiple'], ('yop', 'yep')) + self.assertEqual(cfg['multiple'], ['yop', 'yep']) self.assertEqual(cfg['number'], 2) self.assertEqual(cfg['choice'], 'yo') - self.assertEqual(cfg['multiple-choice'], ('yo', 'ye')) + self.assertEqual(cfg['multiple-choice'], ['yo', 'ye']) self.assertEqual(cfg['named'], {'key': 'val'}) def test_base(self): @@ -207,9 +208,12 @@ diffgroup=pouet""") f = tempfile.mktemp() stream = open(f, 'w') try: + self.cfg['dothis'] = False + self.cfg['multiple'] = ["toto", "tata"] + self.cfg['number'] = 3 cfg.generate_config(stream) stream.close() - new_cfg = MyConfiguration(name='testloop', options=OPTIONS) + new_cfg = MyConfiguration(name='test', options=OPTIONS) new_cfg.load_file_configuration(f) self.assertEqual(cfg['dothis'], new_cfg['dothis']) self.assertEqual(cfg['multiple'], new_cfg['multiple']) @@ -234,18 +238,19 @@ diffgroup=pouet""") # it is not unlikely some optik/optparse versions do print -v # so accept both help = help.replace(' -v , ', ' -v, ') + help = re.sub('[ ]*(\r?\n)', '\\1', help) USAGE = """Usage: Just do it ! (tm) Options: -h, --help show this help message and exit - --dothis= + --dothis= -v, --value= --multiple= you can also document the option [current: yop,yep] --number= boom [current: 2] - --choice= + --choice= --multiple-choice= - --named= + --named= Agroup: --diffgroup= -- cgit v1.2.1