[issue25651] Confusing output for TestCase.subTest(0)

2017-03-31 Thread Donald Stufft

Changes by Donald Stufft :


--
pull_requests: +1077

___
Python tracker 

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



[issue25651] Confusing output for TestCase.subTest(0)

2016-09-21 Thread Berker Peksag

Berker Peksag added the comment:

Fixed. I lost some time because of this today :)

--
nosy: +berker.peksag
resolution:  -> fixed
stage: test needed -> resolved
status: open -> closed
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



[issue25651] Confusing output for TestCase.subTest(0)

2016-09-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ba743894e793 by Berker Peksag in branch '3.5':
Issue #25651: Allow falsy values to be used for msg parameter of subTest()
https://hg.python.org/cpython/rev/ba743894e793

New changeset ddbf92168a44 by Berker Peksag in branch '3.6':
Issue #25651: Merge from 3.5
https://hg.python.org/cpython/rev/ddbf92168a44

New changeset e5888f5b9cf8 by Berker Peksag in branch 'default':
Issue #25651: Merge from 3.6
https://hg.python.org/cpython/rev/e5888f5b9cf8

--
nosy: +python-dev

___
Python tracker 

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



[issue25651] Confusing output for TestCase.subTest(0)

2015-12-16 Thread Zachary Ware

Zachary Ware added the comment:

I think Ezio's suggestion of a sentinel value would be better, allowing None to 
be using as a legitimate 'message' [1].  That is, somewhere at global scope, 
define '_subtest_msg_sentinel = object()', change the msg default at 
Lib/unittest/case.py:500 to be 'msg=_subtest_msg_sentinel', and change the 
check at Lib/unittest/case.py:1400 to check 'if message is not 
_subtest_msg_sentinel'.


[1] For example:

   class TruthTest(unittest.TestCase):
   def test_truth(self):
   for o in None, 1, 0, [], (4,):
   with self.subTest(o):
   self.assertTrue(o)

Should print failure results including '[None]', '[0]', and '[[]]'.

--
nosy: +zach.ware

___
Python tracker 

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



[issue25651] Confusing output for TestCase.subTest(0)

2015-11-21 Thread Nan Wu

Nan Wu added the comment:

Made it check against None explicitly. My concern is if [] is passed in, if 
will show [[]]. But this case should be rare.

--
keywords: +patch
nosy: +Nan Wu
Added file: 
http://bugs.python.org/file41115/subtest_msg_check_against_None.patch

___
Python tracker 

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



[issue25651] Confusing output for TestCase.subTest(0)

2015-11-17 Thread Ezio Melotti

New submission from Ezio Melotti:

When a single positional argument is passed to subTest(), if the argument is 
false, its value won't be displayed in the output -- () will appear 
instead:

>>> import unittest
>>> class NumbersTest(unittest.TestCase):
...   def test_odd(self):
... for i in range(4):
...   with self.subTest(i):  # single positional arg
... self.assertNotEqual(i%2, 0)
... 
>>> unittest.main(exit=False)
==
FAIL: test_odd (__main__.NumbersTest) ()
--
Traceback (most recent call last):
  File "", line 5, in test_odd
AssertionError: 0 == 0
==
FAIL: test_odd (__main__.NumbersTest) [2]
--
Traceback (most recent call last):
  File "", line 5, in test_odd
AssertionError: 0 == 0
--
Ran 1 test in 0.001s
FAILED (failures=2)

This is because subTest() accepts a positional "msg" arg, passes it to _SubTest 
(Lib/unittest/case.py:515), and then _SubTest checks using "if self._message:" 
(Lib/unittest/case.py:1400).

I think it would be better to check the message against a sentinel value 
instead.

--
components: Library (Lib)
keywords: easy
messages: 254827
nosy: ezio.melotti, michael.foord, pitrou, rbcollins
priority: normal
severity: normal
stage: test needed
status: open
title: Confusing output for TestCase.subTest(0)
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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