From b40c3d511065f4d8cca67680040bf3302879dc7e Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 12 May 2009 02:16:02 +0200 Subject: [PATCH] catch duplicate _id values --HG-- branch : trunk --- py/test/funcargs.py | 6 ++++-- py/test/testing/test_funcargs.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/py/test/funcargs.py b/py/test/funcargs.py index e9585f01a..7ebdcd331 100644 --- a/py/test/funcargs.py +++ b/py/test/funcargs.py @@ -39,6 +39,7 @@ class FuncSpecs: self.cls = cls self.module = module self._calls = [] + self._ids = py.builtin.set() def addcall(self, _id=None, **kwargs): for argname in kwargs: @@ -50,8 +51,9 @@ class FuncSpecs: if _id is None: _id = len(self._calls) _id = str(_id) - #if _id in self._ids: - # raise ValueError("duplicate id %r" % _id) + if _id in self._ids: + raise ValueError("duplicate id %r" % _id) + self._ids.add(_id) self._calls.append(CallSpec(_id, kwargs)) class FunctionCollector(py.test.collect.Collector): diff --git a/py/test/testing/test_funcargs.py b/py/test/testing/test_funcargs.py index 6f14bbea4..3ccdc3f1b 100644 --- a/py/test/testing/test_funcargs.py +++ b/py/test/testing/test_funcargs.py @@ -152,6 +152,7 @@ class TestFuncSpecs: funcspec.addcall(_xyz=10) """) funcspec.addcall(_id="hello", arg1=100) + py.test.raises(ValueError, "funcspec.addcall(_id='hello', arg1=100)") call = funcspec._calls[0] assert call.id == "hello" assert call.funcargs == {'arg1': 100}