classification
Title: Test file 'test_keyword.py' submission for use with keyword.py
Type: behavior Stage:
Components: Tests Versions: Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, gregmalcolm, r.david.murray
Priority: normal Keywords: patch

Created on 2010-08-15 05:15 by gregmalcolm, last changed 2010-09-06 16:10 by gregmalcolm.

Files
File name Uploaded Description Edit
test_keyword_v2.patch gregmalcolm, 2010-09-06 16:10 keyword.py tests (2nd attempt)
Messages (3)
msg113942 - (view) Author: Greg Malcolm (gregmalcolm) Date: 2010-08-15 05:15
'keyword.py' didn't have any tests, so I wrote some.

Most of the tests are are for the main() method, which self-populates the keywords section of keyword.py with keywords taken from a grammar file, 'Python/graminit.c'. The main() method allows you to choose the grammar file and the target file, so I've written the tests such that the actual keyword.py does not have to modify itself.

Most of the tests generate dummy keyword.py and graminit.c files for parsing. They are all deleted in the tearUp() stages of each test.

I've timed the tests. In total they take approximately 3 seconds so you may want to tag some of them as "slow". Also I've only tested on the mac, so someone may want to check it runs ok on Windows.

Most of the patch was written at the PyOhio 2010 Sprints. Thanks go to David Murray for advice given while working on it.
msg114909 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-25 13:56
Greg, thanks for working on this.

I haven't looked over the whole patch yet, but there's one thing I noticed right away that needs to be fixed.  'python.exe' is the name of the python executable only on OS X, and the tests are not always run from the build directory.  To make the test OS and location independent you should instead use subprocess.Popen to run the tests, with sys.executable as the program to run.  (You can take a look at how other tests in the test suite do this by searching for sys.executable in the test suite.)
msg115712 - (view) Author: Greg Malcolm (gregmalcolm) Date: 2010-09-06 16:10
Thanks for the feedback David! I've replaced the old patch with a new version that uses Popen/sys.executable as suggested.

- Greg
History
Date User Action Args
2010-09-06 16:10:58gregmalcolmsetfiles: + test_keyword_v2.patch

messages: + msg115712
2010-09-06 16:05:55gregmalcolmsetfiles: - test_keyword.patch
2010-08-25 13:56:51r.david.murraysetmessages: + msg114909
2010-08-15 12:26:00pitrousetnosy: + benjamin.peterson
2010-08-15 05:15:45gregmalcolmcreate