diff options
author | Anthony Truchet <anthony.truchet@logilab.fr> | 2013-10-25 17:30:46 +0200 |
---|---|---|
committer | Anthony Truchet <anthony.truchet@logilab.fr> | 2013-10-25 17:30:46 +0200 |
commit | 9e859c4f6436385d937bb96b949bc66cf6c18bab (patch) | |
tree | b5e598d71d9718e2ca3b867f02916fb576a0b067 | |
parent | 49bb07201f929b462ebeecfc6e030ebd19865028 (diff) | |
download | logilab-common-9e859c4f6436385d937bb96b949bc66cf6c18bab.tar.gz |
[test] Fix broken unittest_configuration.py:ConfigurationTC.test_round_trip
-rw-r--r-- | test/unittest_configuration.py | 21 |
1 files 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': '<y or n>'}), ('value', {'type': 'string', 'metavar': '<string>', 'short': 'v'}), - ('multiple', {'type': 'csv', 'default': ('yop', 'yep'), + ('multiple', {'type': 'csv', 'default': ['yop', 'yep'], 'metavar': '<comma separated values>', 'help': 'you can also document the option'}), ('number', {'type': 'int', 'default':2, 'metavar':'<int>', 'help': 'boom'}), ('choice', {'type': 'choice', 'default':'yo', 'choices': ('yo', 'ye'), 'metavar':'<yo|ye>'}), - ('multiple-choice', {'type': 'multiple_choice', 'default':('yo', 'ye'), + ('multiple-choice', {'type': 'multiple_choice', 'default':['yo', 'ye'], 'choices': ('yo', 'ye', 'yu', 'yi', 'ya'), 'metavar':'<yo|ye>'}), ('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<string> # so accept both help = help.replace(' -v <string>, ', ' -v<string>, ') + help = re.sub('[ ]*(\r?\n)', '\\1', help) USAGE = """Usage: Just do it ! (tm) Options: -h, --help show this help message and exit - --dothis=<y or n> + --dothis=<y or n> -v<string>, --value=<string> --multiple=<comma separated values> you can also document the option [current: yop,yep] --number=<int> boom [current: 2] - --choice=<yo|ye> + --choice=<yo|ye> --multiple-choice=<yo|ye> - --named=<key=val> + --named=<key=val> Agroup: --diffgroup=<key=val> |