|
8 | 8 | from future import utils |
9 | 9 |
|
10 | 10 | from numbers import Integral |
11 | | -from future.tests.base import unittest, expectedFailurePY2, expectedFailurePY33_and_PY34 |
| 11 | +from future.tests.base import unittest, expectedFailurePY2 |
12 | 12 |
|
13 | 13 |
|
14 | 14 | TEST_UNICODE_STR = u'ℝεα∂@ßʟ℮ ☂ℯṧт υηḯ¢☺ḓ℮' |
@@ -552,106 +552,103 @@ def test_maketrans(self): |
552 | 552 | self.assertRaises(ValueError, bytes.maketrans, b'abc', b'xyzq') |
553 | 553 | self.assertRaises(TypeError, bytes.maketrans, 'abc', 'def') |
554 | 554 |
|
555 | | - @expectedFailurePY33_and_PY34 |
556 | | - def test_mod(self): |
557 | | - """ |
558 | | - From Py3.5 test suite (post-PEP 461). |
559 | | -
|
560 | | - The bytes mod code is in _PyBytes_Format() in bytesobject.c in Py3.5. |
561 | | - """ |
562 | | - b = b'hello, %b!' |
563 | | - orig = b |
564 | | - b = b % b'world' |
565 | | - self.assertEqual(b, b'hello, world!') |
566 | | - self.assertEqual(orig, b'hello, %b!') |
567 | | - self.assertFalse(b is orig) |
568 | | - b = b'%s / 100 = %d%%' |
569 | | - a = b % (b'seventy-nine', 79) |
570 | | - self.assertEqual(a, b'seventy-nine / 100 = 79%') |
571 | | - |
572 | | - @expectedFailurePY33_and_PY34 |
573 | | - def test_imod(self): |
574 | | - """ |
575 | | - From Py3.5 test suite (post-PEP 461) |
576 | | - """ |
577 | | - # if (3, 0) <= sys.version_info[:2] < (3, 5): |
578 | | - # raise unittest.SkipTest('bytes % not yet implemented on Py3.0-3.4') |
579 | | - b = bytes(b'hello, %b!') |
580 | | - orig = b |
581 | | - b %= b'world' |
582 | | - self.assertEqual(b, b'hello, world!') |
583 | | - self.assertEqual(orig, b'hello, %b!') |
584 | | - self.assertFalse(b is orig) |
585 | | - b = bytes(b'%s / 100 = %d%%') |
586 | | - b %= (b'seventy-nine', 79) |
587 | | - self.assertEqual(b, b'seventy-nine / 100 = 79%') |
588 | | - |
589 | | - @expectedFailurePY33_and_PY34 |
590 | | - def test_mod_pep_461(self): |
591 | | - """ |
592 | | - Test for the PEP 461 functionality (resurrection of %s formatting for |
593 | | - bytes). |
594 | | - """ |
595 | | - b1 = bytes(b'abc%b') |
596 | | - b2 = b1 % b'def' |
597 | | - self.assertEqual(b2, b'abcdef') |
598 | | - self.assertTrue(isinstance(b2, bytes)) |
599 | | - self.assertEqual(type(b2), bytes) |
600 | | - b3 = b1 % bytes(b'def') |
601 | | - self.assertEqual(b3, b'abcdef') |
602 | | - self.assertTrue(isinstance(b3, bytes)) |
603 | | - self.assertEqual(type(b3), bytes) |
604 | | - |
605 | | - # %s is supported for backwards compatibility with Py2's str |
606 | | - b4 = bytes(b'abc%s') |
607 | | - b5 = b4 % b'def' |
608 | | - self.assertEqual(b5, b'abcdef') |
609 | | - self.assertTrue(isinstance(b5, bytes)) |
610 | | - self.assertEqual(type(b5), bytes) |
611 | | - b6 = b4 % bytes(b'def') |
612 | | - self.assertEqual(b6, b'abcdef') |
613 | | - self.assertTrue(isinstance(b6, bytes)) |
614 | | - self.assertEqual(type(b6), bytes) |
615 | | - |
616 | | - self.assertEqual(bytes(b'%c') % 48, b'0') |
617 | | - self.assertEqual(bytes(b'%c') % b'a', b'a') |
618 | | - |
619 | | - # For any numeric code %x, formatting of |
620 | | - # b"%x" % val |
621 | | - # is supposed to be equivalent to |
622 | | - # ("%x" % val).encode("ascii") |
623 | | - for code in b'xdiouxXeEfFgG': |
624 | | - bytechar = bytes([code]) |
625 | | - pct_str = u"%" + bytechar.decode('ascii') |
626 | | - for val in range(300): |
627 | | - self.assertEqual(bytes(b"%" + bytechar) % val, |
628 | | - (pct_str % val).encode("ascii")) |
629 | | - |
630 | | - with self.assertRaises(TypeError): |
631 | | - bytes(b'%b') % 3.14 |
632 | | - # Traceback (most recent call last): |
633 | | - # ... |
634 | | - # TypeError: b'%b' does not accept 'float' |
635 | | - |
636 | | - with self.assertRaises(TypeError): |
637 | | - bytes(b'%b') % 'hello world!' |
638 | | - # Traceback (most recent call last): |
639 | | - # ... |
640 | | - # TypeError: b'%b' does not accept 'str' |
641 | | - |
642 | | - self.assertEqual(bytes(b'%a') % 3.14, b'3.14') |
643 | | - |
644 | | - self.assertEqual(bytes(b'%a') % b'abc', b"b'abc'") |
645 | | - self.assertEqual(bytes(b'%a') % bytes(b'abc'), b"b'abc'") |
646 | | - |
647 | | - self.assertEqual(bytes(b'%a') % 'def', b"'def'") |
648 | | - |
649 | | - # PEP 461 was updated after an Py3.5 alpha release to specify that %r is now supported |
650 | | - # for compatibility: http://legacy.python.org/dev/peps/pep-0461/#id16 |
651 | | - assert bytes(b'%r' % b'abc') == bytes(b'%a' % b'abc') |
652 | | - |
653 | | - # with self.assertRaises(TypeError): |
654 | | - # bytes(b'%r' % 'abc') |
| 555 | + # def test_mod(self): |
| 556 | + # """ |
| 557 | + # From Py3.5 test suite (post-PEP 461). |
| 558 | + # |
| 559 | + # The bytes mod code is in _PyBytes_Format() in bytesobject.c in Py3.5. |
| 560 | + # """ |
| 561 | + # b = b'hello, %b!' |
| 562 | + # orig = b |
| 563 | + # b = b % b'world' |
| 564 | + # self.assertEqual(b, b'hello, world!') |
| 565 | + # self.assertEqual(orig, b'hello, %b!') |
| 566 | + # self.assertFalse(b is orig) |
| 567 | + # b = b'%s / 100 = %d%%' |
| 568 | + # a = b % (b'seventy-nine', 79) |
| 569 | + # self.assertEqual(a, b'seventy-nine / 100 = 79%') |
| 570 | + |
| 571 | + # def test_imod(self): |
| 572 | + # """ |
| 573 | + # From Py3.5 test suite (post-PEP 461) |
| 574 | + # """ |
| 575 | + # # if (3, 0) <= sys.version_info[:2] < (3, 5): |
| 576 | + # # raise unittest.SkipTest('bytes % not yet implemented on Py3.0-3.4') |
| 577 | + # b = bytes(b'hello, %b!') |
| 578 | + # orig = b |
| 579 | + # b %= b'world' |
| 580 | + # self.assertEqual(b, b'hello, world!') |
| 581 | + # self.assertEqual(orig, b'hello, %b!') |
| 582 | + # self.assertFalse(b is orig) |
| 583 | + # b = bytes(b'%s / 100 = %d%%') |
| 584 | + # b %= (b'seventy-nine', 79) |
| 585 | + # self.assertEqual(b, b'seventy-nine / 100 = 79%') |
| 586 | + |
| 587 | + # def test_mod_pep_461(self): |
| 588 | + # """ |
| 589 | + # Test for the PEP 461 functionality (resurrection of %s formatting for |
| 590 | + # bytes). |
| 591 | + # """ |
| 592 | + # b1 = bytes(b'abc%b') |
| 593 | + # b2 = b1 % b'def' |
| 594 | + # self.assertEqual(b2, b'abcdef') |
| 595 | + # self.assertTrue(isinstance(b2, bytes)) |
| 596 | + # self.assertEqual(type(b2), bytes) |
| 597 | + # b3 = b1 % bytes(b'def') |
| 598 | + # self.assertEqual(b3, b'abcdef') |
| 599 | + # self.assertTrue(isinstance(b3, bytes)) |
| 600 | + # self.assertEqual(type(b3), bytes) |
| 601 | + # |
| 602 | + # # %s is supported for backwards compatibility with Py2's str |
| 603 | + # b4 = bytes(b'abc%s') |
| 604 | + # b5 = b4 % b'def' |
| 605 | + # self.assertEqual(b5, b'abcdef') |
| 606 | + # self.assertTrue(isinstance(b5, bytes)) |
| 607 | + # self.assertEqual(type(b5), bytes) |
| 608 | + # b6 = b4 % bytes(b'def') |
| 609 | + # self.assertEqual(b6, b'abcdef') |
| 610 | + # self.assertTrue(isinstance(b6, bytes)) |
| 611 | + # self.assertEqual(type(b6), bytes) |
| 612 | + # |
| 613 | + # self.assertEqual(bytes(b'%c') % 48, b'0') |
| 614 | + # self.assertEqual(bytes(b'%c') % b'a', b'a') |
| 615 | + # |
| 616 | + # # For any numeric code %x, formatting of |
| 617 | + # # b"%x" % val |
| 618 | + # # is supposed to be equivalent to |
| 619 | + # # ("%x" % val).encode("ascii") |
| 620 | + # for code in b'xdiouxXeEfFgG': |
| 621 | + # bytechar = bytes([code]) |
| 622 | + # pct_str = u"%" + bytechar.decode('ascii') |
| 623 | + # for val in range(300): |
| 624 | + # self.assertEqual(bytes(b"%" + bytechar) % val, |
| 625 | + # (pct_str % val).encode("ascii")) |
| 626 | + # |
| 627 | + # with self.assertRaises(TypeError): |
| 628 | + # bytes(b'%b') % 3.14 |
| 629 | + # # Traceback (most recent call last): |
| 630 | + # # ... |
| 631 | + # # TypeError: b'%b' does not accept 'float' |
| 632 | + # |
| 633 | + # with self.assertRaises(TypeError): |
| 634 | + # bytes(b'%b') % 'hello world!' |
| 635 | + # # Traceback (most recent call last): |
| 636 | + # # ... |
| 637 | + # # TypeError: b'%b' does not accept 'str' |
| 638 | + # |
| 639 | + # self.assertEqual(bytes(b'%a') % 3.14, b'3.14') |
| 640 | + # |
| 641 | + # self.assertEqual(bytes(b'%a') % b'abc', b"b'abc'") |
| 642 | + # self.assertEqual(bytes(b'%a') % bytes(b'abc'), b"b'abc'") |
| 643 | + # |
| 644 | + # self.assertEqual(bytes(b'%a') % 'def', b"'def'") |
| 645 | + # |
| 646 | + # # PEP 461 was updated after an Py3.5 alpha release to specify that %r is now supported |
| 647 | + # # for compatibility: http://legacy.python.org/dev/peps/pep-0461/#id16 |
| 648 | + # assert bytes(b'%r' % b'abc') == bytes(b'%a' % b'abc') |
| 649 | + # |
| 650 | + # # with self.assertRaises(TypeError): |
| 651 | + # # bytes(b'%r' % 'abc') |
655 | 652 |
|
656 | 653 | @expectedFailurePY2 |
657 | 654 | def test_multiple_inheritance(self): |
|
0 commit comments