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: Proposed Syntax Checks in Test Suite
Type: enhancement Stage:
Components: Tests Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: ChuckRhode, benjamin.peterson
Priority: normal Keywords: patch

Created on 2009-10-26 19:40 by ChuckRhode, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_grammar.patch ChuckRhode, 2009-10-26 23:25 Patch against 2.5
test_grammar_trunk.diff ChuckRhode, 2009-10-31 03:40 Patch against Trunk
Messages (12)
msg94501 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-26 19:40
PythonTidy is a code beautifier written three years ago and downloaded
numerous times.

o http://lacusveris.com/PythonTidy/PythonTidy.python

It suffers a bug, which has only recently come to light.  It considers
the following lines equivalent:

  if False is (2 is 3): pass

  if False is 2 is 3: pass

They're not.  PythonTidy handles other non-associative operators such as
division correctly.  I was unable to generalize from arithmetic
operators to comparison operators because the Abstract Syntax Tree (AST)
generated by the *compiler* module returns a different structure for them.  

I tested PythonTidy by running the Python Test Suite (the *test* module
scripts) through it and executing the results, thought I had all my
bases covered because most tests succeeded, and missed this case, so I
am suggesting an amplification of the Python Test Suite for developers
who may be using it for purposes other than testing Python.

I wish to add these lines to the foot of *test_grammar.py*.

  verify(16 // (4 // 2) == 8, '16 // (4 // 2) == 8')
  verify((16 // 4) // 2 == 2, '(16 // 4) // 2 == 2')
  verify(16 // 4 // 2 == 2, '16 // 4 // 2 == 2')
  verify((False is (2 is 3)) == True, '(False is (2 is 3)) == True')
  verify(((False is 2) is 3) == False, '(((False is 2) is 3) == False')
  verify((False is 2 is 3) == False, '(False is 2 is 3) == False')
msg94503 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-26 20:16
Please provided a unified diff against the trunk.
msg94539 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-26 23:14
You mean like this?
msg94540 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-26 23:25
Well, the last two patch files weren't very good, but I hope the third
time's the charm.
msg94541 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-26 23:27
That still looks like it's against Python 2.5.
msg94569 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-27 18:18
Yet another patch file....
msg94639 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-28 21:02
Please just add your test case to the bottom of the trunk...
msg94692 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-30 02:51
Sorry I'm having so much trouble with this patch.  Here's another. 
Thanks for your patience.  -ccr-
msg94732 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-30 22:19
See how all the other tests in test_grammar are written in a unittest style?
msg94742 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-31 03:40
Oh!  That's very different.  :-)

I can do that.
msg94743 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-31 03:56
Applied with some changes in r75971.
msg94757 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-31 14:09
Thanks.  -ccr-
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51459
2009-10-31 14:09:37ChuckRhodesetmessages: + msg94757
2009-10-31 03:56:37benjamin.petersonsetstatus: open -> closed
resolution: accepted
messages: + msg94743
2009-10-31 03:40:36ChuckRhodesetfiles: + test_grammar_trunk.diff

messages: + msg94742
2009-10-31 03:36:13ChuckRhodesetfiles: - test_grammar.patch
2009-10-30 22:19:43benjamin.petersonsetmessages: + msg94732
2009-10-30 02:51:26ChuckRhodesetfiles: + test_grammar.patch

messages: + msg94692
2009-10-30 02:50:01ChuckRhodesetfiles: - test_grammar.patch
2009-10-28 21:02:27benjamin.petersonsetmessages: + msg94639
2009-10-27 18:18:31ChuckRhodesetfiles: + test_grammar.patch

messages: + msg94569
2009-10-26 23:27:15benjamin.petersonsetmessages: + msg94541
2009-10-26 23:25:37ChuckRhodesetfiles: + test_grammar.patch

messages: + msg94540
2009-10-26 23:23:54ChuckRhodesetfiles: - test_grammar.patch
2009-10-26 23:17:50ChuckRhodesetfiles: - test_grammar.patch
2009-10-26 23:14:54ChuckRhodesetfiles: + test_grammar.patch

messages: + msg94539
2009-10-26 20:16:03benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg94503
2009-10-26 19:40:18ChuckRhodecreate