summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-07-17 21:46:25 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-07-17 21:46:25 (GMT)
commit11a70c79b90d106bfe2b4db7039c4fa12f1fc145 (patch)
treef325e4e1b681f54d8365706e8f2fbc07e474e5d2 /Lib/test/test_compile.py
parent910d8f1e89c8f21b5337aa13394e5c153abf1350 (diff)
downloadcpython-11a70c79b90d106bfe2b4db7039c4fa12f1fc145.zip
cpython-11a70c79b90d106bfe2b4db7039c4fa12f1fc145.tar.gz
cpython-11a70c79b90d106bfe2b4db7039c4fa12f1fc145.tar.bz2
Upgrade None assignment SyntaxWarning to a SyntaxError.
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r--Lib/test/test_compile.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index e2b1c95..5b7b717 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -138,6 +138,21 @@ if 1:
self.assertEqual(i, 1)
self.assertEqual(j, -1)
+ def test_none_assignment(self):
+ stmts = [
+ 'None = 0',
+ 'None += 0',
+ '__builtins__.None = 0',
+ 'def None(): pass',
+ 'class None: pass',
+ '(a, None) = 0, 0',
+ 'for None in range(10): pass',
+ 'def f(None): pass',
+ ]
+ for stmt in stmts:
+ stmt += "\n"
+ self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'single')
+ self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'exec')
def test_main():
test_support.run_unittest(TestSpecifics)