Re: name lookup failure using metaclasses with unittests

2013-04-12 Thread Terry Jan Reedy
On 4/12/2013 3:17 AM, Ulrich Eckhardt wrote: Am 11.04.2013 10:19, schrieb Steven D'Aprano: if sys.version >= '3': Use sys.version_info >= (3,), otherwise your code breaks when upgrading to Python 10 and greater. ;^) The second question that came up was if there is a way to keep a metaclass

Re: name lookup failure using metaclasses with unittests

2013-04-12 Thread Ulrich Eckhardt
Am 11.04.2013 10:19, schrieb Steven D'Aprano: if sys.version >= '3': Use sys.version_info >= (3,), otherwise your code breaks when upgrading to Python 10 and greater. ;^) The second question that came up was if there is a way to keep a metaclass defined inside the class or if the only way

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Arnaud Delobelle
On 11 April 2013 07:43, Ulrich Eckhardt wrote: > The second question that came up was if there is a way to keep a metaclass > defined inside the class or if the only way is to provide it externally. Yes, using metaclasses! I wouldn't recommend it though. Here's a proof of concept: class MyTyp

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Steven D'Aprano
On Thu, 11 Apr 2013 08:43:58 +0200, Ulrich Eckhardt wrote: > The first thing I was wondering was why Python doesn't complain about a > class property that is marked as special (leading and trailing double > underscores) but that it knows nothing about. Because that breaks backward compatibility

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Ulrich Eckhardt
Am 10.04.2013 11:52, schrieb Peter Otten: It looks like this particular invocation relies on class attribute and function __name__ being identical. Please file a bug report. http://bugs.python.org/issue17696 Uli -- http://mail.python.org/mailman/listinfo/python-list

Re: name lookup failure using metaclasses with unittests

2013-04-11 Thread Ulrich Eckhardt
Am 10.04.2013 11:52, schrieb Peter Otten: Ulrich Eckhardt wrote: [...] It looks like this particular invocation relies on class attribute and function __name__ being identical. Please file a bug report. Thanks for confirming this and reducing the test case even more. Now, concerning Pytho

Re: name lookup failure using metaclasses with unittests

2013-04-10 Thread Peter Otten
Ulrich Eckhardt wrote: > Hi! > > I'm having problems using a metaclass to generate test functions. This > works when I try to run all tests from the module or test case, but it > fails when I'm trying to specify a single test function. My environment > is Python 2.7.3 on MS Windows 7 at the momen