13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | |
def test_config_cmdline_options(): |
o = py.test.ensuretemp('configoptions') |
o.ensure("conftest.py").write(py.code.Source(""" |
import py |
def _callback(option, opt_str, value, parser, *args, **kwargs): |
option.tdest = True |
Option = py.test.config.Option |
option = py.test.config.addoptions("testing group", |
Option('-G', '--glong', action="store", default=42, |
type="int", dest="gdest", help="g value."), |
# XXX note: special case, option without a destination |
Option('-T', '--tlong', action="callback", callback=_callback, |
help='t value'), |
) |
""")) |
old = o.chdir() |
try: |
config = py.test.config._reparse(['-G', '17']) |
finally: |
-> old.chdir() |
assert config.option.gdest == 17 | |