import pytest


@pytest.mark.xfail(reason="Test assertion rewriting")
class TestMemoryviewAssertion:
    @pytest.fixture()
    def value(self):
        return bytes(_ % 256 for _ in range(10000))

    @pytest.fixture()
    def text(self, value):
        return value.decode("latin1")

    @pytest.fixture()
    def memview(self, value):
        return memoryview(value)

    def test_memview_and_memview(self, memview):
        assert memview == memview[::-1]

    def test_bytes_and_shorter_memview(self, value, memview):
        assert value == memview[:-1]

    def test_shorter_memview_and_bytes(self, value, memview):
        assert memview[:-1] == value

    def test_bytes_and_longer_memview(self, value, memview):
        assert value[:-1] == memview

    def test_longer_memview_and_bytes(self, value, memview):
        assert memview == value[:-1]

    def test_memview_and_str(self, text, memview):
        assert memview == text

    def test_str_and_memview(self, text, memview):
        assert text == memview

@@ -135,16 +135,25 @@
 ue(self)
+ -%3E bytes
 :%0A      
@@ -207,122 +207,29 @@
     
-@pytest.fixture()%0A    def text(self, value):%0A        return value.decode(%22latin1%22)%0A%0A    @pytest.fixture()%0A    def 
+def test_memview_and_
 memv
@@ -243,17 +243,32 @@
 f, value
-)
+: bytes) -%3E None
 :%0A      
@@ -269,22 +269,22 @@
         
-return
+view =
  memoryv
@@ -297,58 +297,8 @@
 lue)
-%0A%0A    def test_memview_and_memview(self, memview):
 %0A   
@@ -309,27 +309,24 @@
  assert 
-mem
 view == 
 memview%5B
@@ -313,27 +313,24 @@
 ert view == 
-mem
 view%5B::-1%5D%0A%0A
@@ -375,35 +375,74 @@
 (self, value
-,
+: bytes) -%3E None:%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A        ass
@@ -450,27 +450,24 @@
 rt value == 
-mem
 view%5B:-1%5D%0A%0A 
@@ -511,35 +511,74 @@
 (self, value
-,
+: bytes) -%3E None:%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A        ass
@@ -577,27 +577,24 @@
      assert 
-mem
 view%5B:-1%5D ==
@@ -646,35 +646,74 @@
 (self, value
-,
+: bytes) -%3E None:%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A        ass
@@ -726,27 +726,24 @@
 lue%5B:-1%5D == 
-mem
 view%0A%0A    de
@@ -785,27 +785,66 @@
 f, value
-,
+: bytes) -%3E None:%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A       
@@ -843,35 +843,32 @@
 %0A        assert 
-mem
 view == value%5B:-
@@ -902,39 +902,117 @@
 d_str(self, 
-text,
+value: bytes) -%3E None:%0A        text = value.decode(%22latin1%22)%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A        ass
@@ -1015,19 +1015,16 @@
  assert 
-mem
 view == 
@@ -1027,16 +1027,52 @@
  == text
+  # type: ignore%5Bcomparison-overlap%5D
 %0A%0A    de
@@ -1104,23 +1104,101 @@
 lf, 
-text,
+value: bytes) -%3E None:%0A        text = value.decode(%22latin1%22)%0A        view =
  mem
+ory
 view
+(value
 )
-:
 %0A   
@@ -1217,16 +1217,49 @@
 text == 
-mem
 view
+  # type: ignore%5Bcomparison-overlap%5D
 %0A

Simplify + annotate