Show More
@@ -434,6 +434,8 b' class KeyValueConfigLoader(CommandLineConfigLoader):' | |||||
434 |
|
434 | |||
435 | if raw == '--': |
|
435 | if raw == '--': | |
436 | # don't parse arguments after '--' |
|
436 | # don't parse arguments after '--' | |
|
437 | # this is useful for relaying arguments to scripts, e.g. | |||
|
438 | # ipython -i foo.py --pylab=qt -- args after '--' go-to-foo.py | |||
437 | self.extra_args.extend(uargv[idx+1:]) |
|
439 | self.extra_args.extend(uargv[idx+1:]) | |
438 | break |
|
440 | break | |
439 |
|
441 | |||
@@ -476,9 +478,7 b' class KeyValueConfigLoader(CommandLineConfigLoader):' | |||||
476 | else: |
|
478 | else: | |
477 | # keep all args that aren't valid in a list, |
|
479 | # keep all args that aren't valid in a list, | |
478 | # in case our parent knows what to do with them. |
|
480 | # in case our parent knows what to do with them. | |
479 |
|
|
481 | self.extra_args.append(item) | |
480 | self.extra_args.extend(uargv[idx:]) |
|
|||
481 | break |
|
|||
482 | return self.config |
|
482 | return self.config | |
483 |
|
483 | |||
484 | class ArgParseConfigLoader(CommandLineConfigLoader): |
|
484 | class ArgParseConfigLoader(CommandLineConfigLoader): |
@@ -128,8 +128,14 b' class TestApplication(TestCase):' | |||||
128 | app = MyApp() |
|
128 | app = MyApp() | |
129 | app.parse_command_line(["--Bar.b=5", 'extra', "--disable", 'args']) |
|
129 | app.parse_command_line(["--Bar.b=5", 'extra', "--disable", 'args']) | |
130 | app.init_bar() |
|
130 | app.init_bar() | |
|
131 | self.assertEquals(app.bar.enabled, False) | |||
|
132 | self.assertEquals(app.bar.b, 5) | |||
|
133 | self.assertEquals(app.extra_args, ['extra', 'args']) | |||
|
134 | app = MyApp() | |||
|
135 | app.parse_command_line(["--Bar.b=5", '--', 'extra', "--disable", 'args']) | |||
|
136 | app.init_bar() | |||
131 | self.assertEquals(app.bar.enabled, True) |
|
137 | self.assertEquals(app.bar.enabled, True) | |
132 | self.assertEquals(app.bar.b, 5) |
|
138 | self.assertEquals(app.bar.b, 5) | |
133 |
self.assertEquals(app.extra_args, ['extra', |
|
139 | self.assertEquals(app.extra_args, ['extra', '--disable', 'args']) | |
134 |
|
140 | |||
135 |
|
141 |
@@ -130,9 +130,9 b' class TestKeyValueCL(TestCase):' | |||||
130 | def test_extra_args(self): |
|
130 | def test_extra_args(self): | |
131 | cl = KeyValueConfigLoader() |
|
131 | cl = KeyValueConfigLoader() | |
132 | config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) |
|
132 | config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) | |
133 |
self.assertEquals(cl.extra_args, ['b', ' |
|
133 | self.assertEquals(cl.extra_args, ['b', 'd']) | |
134 | self.assertEquals(config.a, 5) |
|
134 | self.assertEquals(config.a, 5) | |
135 |
self.assert |
|
135 | self.assertEquals(config.c, 10) | |
136 | config = cl.load_config(['--', '--a=5', '--c=10']) |
|
136 | config = cl.load_config(['--', '--a=5', '--c=10']) | |
137 | self.assertEquals(cl.extra_args, ['--a=5', '--c=10']) |
|
137 | self.assertEquals(cl.extra_args, ['--a=5', '--c=10']) | |
138 |
|
138 |
General Comments 0
You need to be logged in to leave comments.
Login now