[svn r38484] make config.option override any conftest provided value.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-11 18:08:13 +01:00
parent 50f9f1a410
commit bda58e9862
3 changed files with 4 additions and 10 deletions

View File

@ -34,7 +34,6 @@ class Config(object):
usage="usage: %prog [options] [query] [filenames of tests]")
self.conftest = Conftest()
self._initialized = False
self._overwrite_dict = {}
def parse(self, args):
""" parse cmdline arguments into this config object.
@ -127,8 +126,8 @@ class Config(object):
conftest modules found during command line parsing.
"""
try:
return self._overwrite_dict[name]
except KeyError:
return getattr(self.option, name)
except AttributeError:
return self.conftest.rget(name, path)
def initsession(self):
@ -186,11 +185,6 @@ class Config(object):
finally:
config_per_process = py.test.config = oldconfig
def _overwrite(self, name, value):
""" this is used from tests to overwrite values irrespectives of conftests.
"""
self._overwrite_dict[name] = value
def make_repr(self, conftestnames, optnames=None):
""" return a marshallable representation
of conftest and cmdline options.

View File

@ -20,7 +20,7 @@ def setup_module(mod):
mod.tmpdir = tmpdir = py.test.ensuretemp(mod.__name__)
# to avoid rsyncing
config = py.test.config._reparse([tmpdir])
config._overwrite('dist_taskspernode', 10)
config.option.dist_taskspernode = 10
mod.rootcol = config._getcollector(tmpdir)
class DummyGateway(object):

View File

@ -101,7 +101,7 @@ def test_config_overwrite():
o.ensure("conftest.py").write("x=1")
config = py.test.config._reparse([str(o)])
assert config.getvalue('x') == 1
config._overwrite('x', 2)
config.option.x = 2
assert config.getvalue('x') == 2
config = py.test.config._reparse([str(o)])
assert config.getvalue('x') == 1