[Python-Dev] PEP: Consolidating names and classes in the `unittest` module

Scott Dial scott+python-dev at scottdial.com
Tue Jul 15 08:17:21 CEST 2008


Michael Foord wrote:
> Benjamin Peterson wrote:
>> On Mon, Jul 14, 2008 at 6:18 PM, Ben Finney 
>> <ben+python at benfinney.id.au> wrote:
>>> "Benjamin Peterson" <musiccomposition at gmail.com> writes:
>>>> On Mon, Jul 14, 2008 at 8:25 AM, Ben Finney 
>>>> <ben+python at benfinney.id.au> wrote:
>>>>> Use new-style classes throughout
>>>>> --------------------------------
>>>>>
>>>>> The following classes will inherit explicitly from the built-in
>>>>> `object` type, to make all classes in the module part of the new-style
>>>>> type hierarchy.
>>>>>
[snip]
>>>>>         
>>>> They already do. __metaclass__ = type is found in unittest.py.
>>>>       
>>> Not in the copy I have. Is that in 3.x only, or in 2.x also?
>>>     
>>
>> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
>> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>>  
>>>>> import unittest
>>>>> isinstance(unittest.TestCase, object)
>>>>>         
>> True
>>   
> That proves nothing:
> 
> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> class x: pass
> ...
>  >>> isinstance(x, object)
> True
>  >>> isinstance(x, type)
> False
>  >>> type(x)
> <type 'classobj'>
> 

While your retort is accurate, I think it's unintentionally deceptive, 
because you didn't finish your thought.. Benjamin is actually still correct:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit 
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import unittest
 >>> isinstance(unittest.TestCase, type)
True
 >>> type(unittest.TestCase)
<type 'type'>

-- 
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu


More information about the Python-Dev mailing list