[svn r38548] carefully privatizing Config.make_repr and Config.merge_repr

by doing a whole-pylib replace and reviewing the diff in detail

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-12 13:18:23 +01:00
parent 38e3462d98
commit 5d36fbf365
4 changed files with 17 additions and 17 deletions

View File

@ -56,7 +56,7 @@ class Config(object):
assert not self._initialized
self._initialized = True
self.topdir = py.path.local(topdir)
self.merge_repr(repr)
self._mergerepr(repr)
self._coltrails = coltrails
def getcolitems(self):
@ -189,7 +189,7 @@ class Config(object):
finally:
config_per_process = py.test.config = oldconfig
def make_repr(self, conftestnames, optnames=None):
def _makerepr(self, conftestnames, optnames=None):
""" return a marshallable representation
of conftest and cmdline options.
if optnames is None, all options
@ -214,10 +214,10 @@ class Config(object):
l.append(path.relto(self.topdir))
return l, conftestdict, cmdlineopts
def merge_repr(self, repr):
def _mergerepr(self, repr):
""" merge in the conftest and cmdline option values
found in the given representation (produced
by make_repr above).
by _makerepr above).
The repr-contained conftest values are
stored on the default conftest module (last

View File

@ -70,7 +70,7 @@ def slave_main(receive, send, path, config):
defaultconftestnames = ['dist_nicelevel']
def setup_slave(host, config):
channel = host.gw.remote_exec(str(py.code.Source(setup, "setup()")))
configrepr = config.make_repr(defaultconftestnames)
configrepr = config._makerepr(defaultconftestnames)
#print "sending configrepr", configrepr
topdir = host.gw_remotepath
if topdir is None:

View File

@ -104,7 +104,7 @@ class RemoteTerminalSession(Session):
""", stdout=self.out, stderr=self.out)
try:
print "MASTER: initiated slave terminal session ->"
repr = self.config.make_repr(conftestnames=[])
repr = self.config._makerepr(conftestnames=[])
channel.send((str(topdir), repr, failures))
print "MASTER: send start info, topdir=%s" % (topdir,)
try:

View File

@ -128,7 +128,7 @@ def test_config_init_direct():
tmp.ensure("conftest.py").write("x=1 ; y=2")
hello = tmp.ensure("test_hello.py")
config = py.test.config._reparse([hello])
repr = config.make_repr(conftestnames=['x', 'y'])
repr = config._makerepr(conftestnames=['x', 'y'])
config2 = py.test.config._reparse([tmp.dirpath()])
config2._initialized = False # we have to do that from tests
config2.initdirect(topdir=tmp.dirpath(), repr=repr)
@ -148,19 +148,19 @@ def test_config_init_direct():
assert col.parent.name == tmp.basename
assert col.parent.parent is None
def test_config_make_and_merge_repr():
def test_config_make_and__mergerepr():
tmp = py.test.ensuretemp("reprconfig1")
tmp.ensure("__init__.py")
tmp.ensure("conftest.py").write("x=1")
config = py.test.config._reparse([tmp])
repr = config.make_repr(conftestnames=['x'])
repr = config._makerepr(conftestnames=['x'])
config.option.verbose = 42
repr2 = config.make_repr(conftestnames=[], optnames=['verbose'])
repr2 = config._makerepr(conftestnames=[], optnames=['verbose'])
config = py.test.config._reparse([tmp.dirpath()])
py.test.raises(KeyError, "config.getvalue('x')")
config.merge_repr(repr)
config._mergerepr(repr)
assert config.getvalue('x') == 1
config.merge_repr(repr2)
config._mergerepr(repr2)
assert config.option.verbose == 42
def test_config_marshability():
@ -168,11 +168,11 @@ def test_config_marshability():
tmp.ensure("__init__.py")
tmp.ensure("conftest.py").write("a = object()")
config = py.test.config._reparse([tmp])
py.test.raises(ValueError, "config.make_repr(conftestnames=['a'])")
py.test.raises(ValueError, "config._makerepr(conftestnames=['a'])")
config.option.hello = lambda x: None
py.test.raises(ValueError, "config.make_repr(conftestnames=[])")
config.make_repr(conftestnames=[], optnames=[])
py.test.raises(ValueError, "config._makerepr(conftestnames=[])")
config._makerepr(conftestnames=[], optnames=[])
def test_config_rconfig():
tmp = py.test.ensuretemp("rconfigopt")
@ -186,10 +186,10 @@ def test_config_rconfig():
"""))
config = py.test.config._reparse([tmp, "-G", "11"])
assert config.option.gdest == 11
repr = config.make_repr(conftestnames=[])
repr = config._makerepr(conftestnames=[])
config = py.test.config._reparse([tmp.dirpath()])
py.test.raises(AttributeError, "config.option.gdest")
config.merge_repr(repr)
config._mergerepr(repr)
assert config.option.gdest == 11
class TestSessionAndOptions: