[pypy-commit] pypy py3.5-byteformat: add more edges cases to the test as described in the pep 461
plan_rich
pypy.commits at gmail.com
Wed Aug 31 03:14:15 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5-byteformat
Changeset: r86763:0fe90d1f2c7e
Date: 2016-08-31 09:13 +0200
http://bitbucket.org/pypy/pypy/changeset/0fe90d1f2c7e/
Log: add more edges cases to the test as described in the pep 461
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -477,6 +477,9 @@
"character code not in range(256)")
self.std_wp(s)
+ def fmt_b(self, w_value):
+ raise NotImplementedError
+
return StringFormatter
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -874,10 +874,15 @@
assert bytes(64).hex() == "00"*64
def test_format(self):
- assert eval("b'a%db' % 2") == eval("b'a2b'")
- assert eval("b'00%.2f'").__mod__((0.01234)) == eval("b'000.01'")
- assert eval("b'%04X' % 10") == eval("b'000A'")
- assert eval("b'%c' % 48") == eval("b'0'")
- assert eval("b'%c' % b'a'") == eval("b'a'")
- assert eval("b'%b' % b'abc'") == eval("b'abc'")
+ """
+ assert b'a%db' % 2 == b'a2b'
+ assert b'00%.2f'.__mod__((0.01234,)) == b'000.01'
+ assert b'%04X' % 10 == b'000A'
+ assert b'%c' % 48 == b'0'
+ assert b'%c' % b'a' == b'a'
+ assert b'%b' % b'abc' == b'abc'
+ assert b'%b' % 'はい'.encode('utf-8') == b'\xe3\x81\xaf\xe3\x81\x84'
+ raises(TypeError, 'b"%b" % 3.14')
+ raises(TypeError, 'b"%b" % "hello world"')
+ """
More information about the pypy-commit
mailing list