[New-bugs-announce] [issue7210] Proposed Syntax Checks in Test Suite

Chuck Rhode report at bugs.python.org
Mon Oct 26 20:40:20 CET 2009


New submission from Chuck Rhode <CRhode at LacusVeris.com>:

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')

----------
components: Tests
files: test_grammar.patch
keywords: patch
messages: 94501
nosy: ChuckRhode
severity: normal
status: open
title: Proposed Syntax Checks in Test Suite
type: feature request
versions: Python 2.5
Added file: http://bugs.python.org/file15206/test_grammar.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7210>
_______________________________________


More information about the New-bugs-announce mailing list