[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 89f6abc2e115 by Ethan Furman in branch 'default':
Close #19252: better test coverage for Enum.  Thanks, CliffM
http://hg.python.org/cpython/rev/89f6abc2e115

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-14 Thread CliffM

CliffM added the comment:

Sorry -- I could have been clearer :

The conditional:

 if member.value == value:

Is redundant as the tests stand.  If you comment it out -- everything works. So 
therefore we are missing a test.

The current test works, as red is the first value to pop out of the value() 
list.  

This makes the if-clause fragile for future maintenance.  So we need another 
test to ensure the loop is covered.

It's a coverage issue -- where although the code is executed by the test, and 
the code is correct, the test is not complete enough for the code.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-14 Thread Ethan Furman

Ethan Furman added the comment:

CliffM added the comment:

 Sorry -- I could have been clearer :

 The conditional:

   if member.value == value:

 Is redundant as the tests stand.  If you comment it out -- everything works. 
 So therefore we are missing a test.

Are you saying that you are commenting out the if test, but leaving in the 
return member?

 This makes the if-clause fragile for future maintenance.  So we need another 
 test to ensure the loop is covered.

In case Python for loops suddenly stop working?

Sorry to be so dense, but I am not understanding the point you are trying to 
make... ahh!  Are trying to guard 
against the possibility that in the future someone might accidentally delete 
the if test, and the unit test won't catch 
it?  That certainly is a good reason to test values further into the loop.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-14 Thread CliffM

CliffM added the comment:

Yes it's purely a coverage issue.  I must try to be more explicit (rather than 
implicit).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-14 Thread Ethan Furman

Ethan Furman added the comment:

Well, I would say it's half a coverage issue, half a guard against accidental 
deletion of the if test.  :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-13 Thread CliffM

New submission from CliffM:

test_nonhash_value tests the lookup of an Enum Member from a value.

The current test does not exercise the iteration over values completely -- the 
if-clause being redundant wrt the existing test.

My patch adds an additional test which requires the if-clause.

--
components: Extension Modules, Tests
files: enum.patch
keywords: patch
messages: 199800
nosy: CliffM
priority: normal
severity: normal
status: open
title: Enum.py : Enum.__new__() : Test Coverage
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file32099/enum.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19252] Enum.py : Enum.__new__() : Test Coverage

2013-10-13 Thread Ethan Furman

Ethan Furman added the comment:

I'm not sure what you are talking about.  Here's the code:

try:
if value in cls._value2member_map_:
return cls._value2member_map_[value]
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():
if member.value == value:
return member

Here's the test:

self.assertEqual(ColorInAList([1]), ColorInAList.red)

In order for that test to work, the first if (in the try) raises a TypeError, 
then execution falls into the except block and each member is tested for 
equality until one matches (via the if) -- so what is your added test doing 
that isn't already being done?

--
assignee:  - ethan.furman
nosy: +ethan.furman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19252
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com