[svn r63148] add a __repr__ for xspecs
--HG-- branch : trunk
This commit is contained in:
parent
a4c14e83f0
commit
78d1836d80
|
@ -34,6 +34,10 @@ class TestXSpec:
|
|||
for x in ("popen", "popen//python=this"):
|
||||
assert XSpec(x)._spec == x
|
||||
|
||||
def test_repr(self):
|
||||
for x in ("popen", "popen//python=this"):
|
||||
assert repr(XSpec(x)).find("popen") != -1
|
||||
|
||||
def test_hash_equality(self):
|
||||
assert XSpec("popen") == XSpec("popen")
|
||||
assert hash(XSpec("popen")) == hash(XSpec("popen"))
|
||||
|
|
|
@ -22,9 +22,12 @@ class XSpec:
|
|||
key, value = keyvalue[:i], keyvalue[i+1:]
|
||||
# XXX be restrictive for now
|
||||
if key not in XSpec.__dict__:
|
||||
raise AttributeError("%r not a valid attribute" % key)
|
||||
raise AttributeError("%r not a valid XSpec key" % key)
|
||||
setattr(self, key, value)
|
||||
|
||||
def __repr__(self):
|
||||
return "<XSpec %r>" %(self._spec,)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._spec)
|
||||
def __eq__(self, other):
|
||||
|
|
Loading…
Reference in New Issue