From 78d1836d805898340878bd08cd9cf907bf1fd4d3 Mon Sep 17 00:00:00 2001 From: hpk Date: Fri, 20 Mar 2009 17:58:32 +0100 Subject: [PATCH] [svn r63148] add a __repr__ for xspecs --HG-- branch : trunk --- py/execnet/testing/test_xspec.py | 4 ++++ py/execnet/xspec.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/py/execnet/testing/test_xspec.py b/py/execnet/testing/test_xspec.py index 983bd1322..60baf797c 100644 --- a/py/execnet/testing/test_xspec.py +++ b/py/execnet/testing/test_xspec.py @@ -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")) diff --git a/py/execnet/xspec.py b/py/execnet/xspec.py index 0b1f82db7..ceafca329 100644 --- a/py/execnet/xspec.py +++ b/py/execnet/xspec.py @@ -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 "" %(self._spec,) + def __hash__(self): return hash(self._spec) def __eq__(self, other):