This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add test cases for assert
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: benjamin.peterson, ezio.melotti, gnofi, python-dev
Priority: normal Keywords: patch

Created on 2010-04-16 01:49 by gnofi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_grammar.v2.patch gnofi, 2010-04-16 01:49 2.x trunk patch
test_grammar.v3.patch gnofi, 2010-04-16 01:49 3.x trunk patch
test_grammar.v2.patch gnofi, 2010-04-21 23:56 Updated 2.x patch
test_grammar.v3.patch gnofi, 2010-04-21 23:56 Updated 3.x patch
Messages (6)
msg103284 - (view) Author: Gregory Nofi (gnofi) Date: 2010-04-16 01:49
I'm adding some assert tests to test_grammar.py to verify that the assert statement raises (or doesn't raise) an AssertionError properly.

NOTE: I'm currently helping Dino port IronPython tests into CPython. This is part of that series.
msg103286 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-04-16 02:54
I propose you move all the assert test cases into there own test method and decorate it with @unittest.skipUnless(__debug__).
msg103287 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-04-16 02:57
Wouldn't it be better to test e.args instead or in addition to str(e)?
Skipping the whole test if __debug__ is False is also a good idea.
msg103925 - (view) Author: Gregory Nofi (gnofi) Date: 2010-04-21 23:56
I've uploaded new versions of the patch.

__debug__: I removed the "if __debug__" clause and switched to skipUnless.

Exception args: I replaced str(e) with e.args. Thanks for pointing that out! I had thought args was going to be deprecated but I guess it's not (Issue6777).
msg148756 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-12-02 16:24
New changeset bcfb499338c1 by Ezio Melotti in branch '2.7':
#8414: add more tests for "assert".  Initial patch by Gregory Nofi.
http://hg.python.org/cpython/rev/bcfb499338c1

New changeset 1efefeda00a7 by Ezio Melotti in branch '3.2':
#8414: add more tests for "assert".  Initial patch by Gregory Nofi.
http://hg.python.org/cpython/rev/1efefeda00a7

New changeset 47afbb2033aa by Ezio Melotti in branch 'default':
#8414: merge with 3.2.
http://hg.python.org/cpython/rev/47afbb2033aa
msg148757 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-12-02 16:26
Committed, thanks for the patch!
I preferred to add a separate test, because only the tests with "assert False" need to be skipped with -O, the other can run with and without -O.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52661
2011-12-02 16:26:35ezio.melottisetstatus: open -> closed
versions: + Python 3.3
messages: + msg148757

assignee: ezio.melotti
resolution: fixed
stage: patch review -> resolved
2011-12-02 16:24:06python-devsetnosy: + python-dev
messages: + msg148756
2010-04-21 23:56:54gnofisetfiles: + test_grammar.v3.patch
2010-04-21 23:56:31gnofisetfiles: + test_grammar.v2.patch

messages: + msg103925
2010-04-16 02:57:04ezio.melottisetpriority: normal

nosy: + ezio.melotti
messages: + msg103287

stage: patch review
2010-04-16 02:54:28benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg103286
2010-04-16 01:49:28gnofisetfiles: + test_grammar.v3.patch
2010-04-16 01:49:12gnoficreate