classification
Title: Simplify calling and discovery of json test package
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: brett.cannon, ezio.melotti, ned.deily, python-dev, zach.ware
Priority: normal Keywords: patch

Created on 2013-06-20 20:30 by zach.ware, last changed 2013-08-08 12:35 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
test_json_discovery-3.3.diff zach.ware, 2013-06-20 20:30 test_json test_main->unittest.main conversion
test_json_discovery.v2-3.3.diff zach.ware, 2013-08-08 03:03 Version 2
Messages (6)
msg191537 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-06-20 20:30
Technically, test discovery already works for test_json.py / json_tests, but not the way really expected (each test file is discovered individually), and not as simply as it could.  The attached patch does the following:

- remove test_json.py
- rename json_tests to test_json (to match all other tests, following the example of test_email and test_importlib)
- remove main() and 'if __name__ == "__main__"' stanza from __init__.py
- rename test_suite() to load_tests(*args)
- Add test_json/__main__.py, which calls unittest.main

I believe this is the simplest, cleanest way to convert the json tests from test_main to unittest.main().

The patch is against 3.3; there are changes in 3.4 that make a patch against it not apply to 3.3.  It merges forward easily, though.
msg194480 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-05 14:08
I like the patch.
Can you make "./python Lib/test/test_json/" work too?  Currently it doesn't seem to work (it works for e.g. "./python Lib/test/test_email/").
msg194500 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-08-05 18:32
Make sure the tests still work when run from an installed Python rather than just from a build directory.  In particular, if you rename test directories, you will need to change LIBSUBDIRS in Makefile.pre.in to ensure the directories and their files are installed.
msg194640 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2013-08-08 03:03
Here's a new patch; test_json.__main__ now uses an absolute import rather than trying to use a relative one.  Also, Makefile.pre.in is fixed (thank you, Ned!).
msg194664 - (view) Author: Roundup Robot (python-dev) Date: 2013-08-08 12:31
New changeset 95cf8640b271 by Ezio Melotti in branch '3.3':
#18273: move the tests in Lib/test/json_tests to Lib/test/test_json and make them discoverable by unittest.  Patch by Zachary Ware.
http://hg.python.org/cpython/rev/95cf8640b271

New changeset f7ed301e7199 by Ezio Melotti in branch 'default':
#18273: merge with 3.3.
http://hg.python.org/cpython/rev/f7ed301e7199
msg194665 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-08 12:35
Fixed, thanks for the patch!
(Thanks Ned too!)
History
Date User Action Args
2013-08-08 12:35:23ezio.melottisetstatus: open -> closed
messages: + msg194665

assignee: ezio.melotti
resolution: fixed
stage: patch review -> resolved
2013-08-08 12:31:47python-devsetnosy: + python-dev
messages: + msg194664
2013-08-08 03:03:33zach.waresetfiles: + test_json_discovery.v2-3.3.diff

messages: + msg194640
2013-08-05 18:32:43ned.deilysetnosy: + ned.deily
messages: + msg194500
2013-08-05 14:08:50ezio.melottisetmessages: + msg194480
stage: patch review
2013-06-20 20:30:20zach.warecreate