Show More
@@ -621,9 +621,9 b' class KVArgParseConfigLoader(ArgParseConfigLoader):' | |||||
621 | else: |
|
621 | else: | |
622 | nargs = None |
|
622 | nargs = None | |
623 | if len(key) is 1: |
|
623 | if len(key) is 1: | |
624 |
paa('-'+key, '--'+key, type= |
|
624 | paa('-'+key, '--'+key, type=unicode, dest=value, nargs=nargs) | |
625 | else: |
|
625 | else: | |
626 |
paa('--'+key, type= |
|
626 | paa('--'+key, type=unicode, dest=value, nargs=nargs) | |
627 | for key, (value, help) in flags.iteritems(): |
|
627 | for key, (value, help) in flags.iteritems(): | |
628 | if key in self.aliases: |
|
628 | if key in self.aliases: | |
629 | # |
|
629 | # |
@@ -35,6 +35,7 b' from IPython.config.loader import (' | |||||
35 | PyFileConfigLoader, |
|
35 | PyFileConfigLoader, | |
36 | KeyValueConfigLoader, |
|
36 | KeyValueConfigLoader, | |
37 | ArgParseConfigLoader, |
|
37 | ArgParseConfigLoader, | |
|
38 | KVArgParseConfigLoader, | |||
38 | ConfigError |
|
39 | ConfigError | |
39 | ) |
|
40 | ) | |
40 |
|
41 | |||
@@ -117,9 +118,10 b' class TestArgParseCL(TestCase):' | |||||
117 |
|
118 | |||
118 |
|
119 | |||
119 | class TestKeyValueCL(TestCase): |
|
120 | class TestKeyValueCL(TestCase): | |
|
121 | klass = KeyValueConfigLoader | |||
120 |
|
122 | |||
121 | def test_basic(self): |
|
123 | def test_basic(self): | |
122 | cl = KeyValueConfigLoader() |
|
124 | cl = self.klass() | |
123 | argv = ['--'+s.strip('c.') for s in pyfile.split('\n')[2:-1]] |
|
125 | argv = ['--'+s.strip('c.') for s in pyfile.split('\n')[2:-1]] | |
124 | with mute_warn(): |
|
126 | with mute_warn(): | |
125 | config = cl.load_config(argv) |
|
127 | config = cl.load_config(argv) | |
@@ -130,7 +132,7 b' class TestKeyValueCL(TestCase):' | |||||
130 | self.assertEquals(config.D.C.value, 'hi there') |
|
132 | self.assertEquals(config.D.C.value, 'hi there') | |
131 |
|
133 | |||
132 | def test_extra_args(self): |
|
134 | def test_extra_args(self): | |
133 | cl = KeyValueConfigLoader() |
|
135 | cl = self.klass() | |
134 | with mute_warn(): |
|
136 | with mute_warn(): | |
135 | config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) |
|
137 | config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) | |
136 | self.assertEquals(cl.extra_args, ['b', 'd']) |
|
138 | self.assertEquals(cl.extra_args, ['b', 'd']) | |
@@ -141,7 +143,7 b' class TestKeyValueCL(TestCase):' | |||||
141 | self.assertEquals(cl.extra_args, ['--a=5', '--c=10']) |
|
143 | self.assertEquals(cl.extra_args, ['--a=5', '--c=10']) | |
142 |
|
144 | |||
143 | def test_unicode_args(self): |
|
145 | def test_unicode_args(self): | |
144 | cl = KeyValueConfigLoader() |
|
146 | cl = self.klass() | |
145 | argv = [u'--a=épsîlön'] |
|
147 | argv = [u'--a=épsîlön'] | |
146 | with mute_warn(): |
|
148 | with mute_warn(): | |
147 | config = cl.load_config(argv) |
|
149 | config = cl.load_config(argv) | |
@@ -154,11 +156,21 b' class TestKeyValueCL(TestCase):' | |||||
154 | except (TypeError, UnicodeEncodeError): |
|
156 | except (TypeError, UnicodeEncodeError): | |
155 | raise SkipTest("sys.stdin.encoding can't handle 'é'") |
|
157 | raise SkipTest("sys.stdin.encoding can't handle 'é'") | |
156 |
|
158 | |||
157 | cl = KeyValueConfigLoader() |
|
159 | cl = self.klass() | |
158 | with mute_warn(): |
|
160 | with mute_warn(): | |
159 | config = cl.load_config([barg]) |
|
161 | config = cl.load_config([barg]) | |
160 | self.assertEquals(config.a, u'é') |
|
162 | self.assertEquals(config.a, u'é') | |
161 |
|
163 | |||
|
164 | def test_unicode_alias(self): | |||
|
165 | cl = self.klass() | |||
|
166 | argv = [u'--a=épsîlön'] | |||
|
167 | with mute_warn(): | |||
|
168 | config = cl.load_config(argv, aliases=dict(a='A.a')) | |||
|
169 | self.assertEquals(config.A.a, u'épsîlön') | |||
|
170 | ||||
|
171 | ||||
|
172 | class TestArgParseKVCL(TestKeyValueCL): | |||
|
173 | klass = KVArgParseConfigLoader | |||
162 |
|
174 | |||
163 | class TestConfig(TestCase): |
|
175 | class TestConfig(TestCase): | |
164 |
|
176 |
General Comments 0
You need to be logged in to leave comments.
Login now