[pypy-commit] pypy py3k: improve datetime test_backdoor_resistance
bdkearns
noreply at buildbot.pypy.org
Fri Mar 8 23:51:59 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: py3k
Changeset: r62256:32627dc63db2
Date: 2013-03-08 17:49 -0500
http://bitbucket.org/pypy/pypy/changeset/32627dc63db2/
Log: improve datetime test_backdoor_resistance
diff --git a/lib-python/3/test/datetimetester.py b/lib-python/3/test/datetimetester.py
--- a/lib-python/3/test/datetimetester.py
+++ b/lib-python/3/test/datetimetester.py
@@ -1380,9 +1380,10 @@
for month_byte in b'9', b'\0', b'\r', b'\xff':
self.assertRaises(TypeError, self.theclass,
base[:2] + month_byte + base[3:])
- # Good bytes, but bad tzinfo:
- self.assertRaises(TypeError, self.theclass,
- bytes([1] * len(base)), 'EST')
+ if issubclass(self.theclass, datetime):
+ # Good bytes, but bad tzinfo:
+ with self.assertRaisesRegex(TypeError, '^bad tzinfo state arg$'):
+ self.theclass(bytes([1] * len(base)), 'EST')
for ord_byte in range(1, 13):
# This shouldn't blow up because of the month byte alone. If
@@ -2275,6 +2276,9 @@
for hour_byte in ' ', '9', chr(24), '\xff':
self.assertRaises(TypeError, self.theclass,
hour_byte + base[1:])
+ # Good bytes, but bad tzinfo:
+ with self.assertRaisesRegex(TypeError, '^bad tzinfo state arg$'):
+ self.theclass(bytes([1] * len(base)), 'EST')
# A mixin for classes with a tzinfo= argument. Subclasses must define
# theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever)
More information about the pypy-commit
mailing list