Patchwork D3369: tests: add all missing b prefixes in reactor tests

login
register
mail settings
Submitter phabricator
Date April 14, 2018, 5:37 a.m.
Message ID <differential-rev-PHID-DREV-7uwqrbowt3jmr4riboku-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30994/
State Superseded
Headers show

Comments

phabricator - April 14, 2018, 5:37 a.m.
durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Both of these tests now pass on Python 3.
  
  1. skip-blame just b prefixes. So many b prefixes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3369

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-wireproto-clientreactor.py
  tests/test-wireproto-serverreactor.py

CHANGE DETAILS




To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-wireproto-serverreactor.py b/tests/test-wireproto-serverreactor.py
--- a/tests/test-wireproto-serverreactor.py
+++ b/tests/test-wireproto-serverreactor.py
@@ -62,58 +62,58 @@ 
         stream = framing.stream(1)
         results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {}))
         self.assertEqual(len(results), 1)
-        self.assertaction(results[0], 'runcommand')
+        self.assertaction(results[0], b'runcommand')
         self.assertEqual(results[0][1], {
-            'requestid': 1,
-            'command': b'mycommand',
-            'args': {},
-            'data': None,
+            b'requestid': 1,
+            b'command': b'mycommand',
+            b'args': {},
+            b'data': None,
         })
 
         result = reactor.oninputeof()
-        self.assertaction(result, 'noop')
+        self.assertaction(result, b'noop')
 
     def test1argument(self):
         reactor = makereactor()
         stream = framing.stream(1)
         results = list(sendcommandframes(reactor, stream, 41, b'mycommand',
                                          {b'foo': b'bar'}))
         self.assertEqual(len(results), 1)
-        self.assertaction(results[0], 'runcommand')
+        self.assertaction(results[0], b'runcommand')
         self.assertEqual(results[0][1], {
-            'requestid': 41,
-            'command': b'mycommand',
-            'args': {b'foo': b'bar'},
-            'data': None,
+            b'requestid': 41,
+            b'command': b'mycommand',
+            b'args': {b'foo': b'bar'},
+            b'data': None,
         })
 
     def testmultiarguments(self):
         reactor = makereactor()
         stream = framing.stream(1)
         results = list(sendcommandframes(reactor, stream, 1, b'mycommand',
                                          {b'foo': b'bar', b'biz': b'baz'}))
         self.assertEqual(len(results), 1)
-        self.assertaction(results[0], 'runcommand')
+        self.assertaction(results[0], b'runcommand')
         self.assertEqual(results[0][1], {
-            'requestid': 1,
-            'command': b'mycommand',
-            'args': {b'foo': b'bar', b'biz': b'baz'},
-            'data': None,
+            b'requestid': 1,
+            b'command': b'mycommand',
+            b'args': {b'foo': b'bar', b'biz': b'baz'},
+            b'data': None,
         })
 
     def testsimplecommanddata(self):
         reactor = makereactor()
         stream = framing.stream(1)
         results = list(sendcommandframes(reactor, stream, 1, b'mycommand', {},
                                          util.bytesio(b'data!')))
         self.assertEqual(len(results), 2)
-        self.assertaction(results[0], 'wantframe')
-        self.assertaction(results[1], 'runcommand')
+        self.assertaction(results[0], b'wantframe')
+        self.assertaction(results[1], b'runcommand')
         self.assertEqual(results[1][1], {
-            'requestid': 1,
-            'command': b'mycommand',
-            'args': {},
-            'data': b'data!',
+            b'requestid': 1,
+            b'command': b'mycommand',
+            b'args': {},
+            b'data': b'data!',
         })
 
     def testmultipledataframes(self):
@@ -129,13 +129,13 @@ 
         results = list(sendframes(reactor, frames))
         self.assertEqual(len(results), 4)
         for i in range(3):
-            self.assertaction(results[i], 'wantframe')
-        self.assertaction(results[3], 'runcommand')
+            self.assertaction(results[i], b'wantframe')
+        self.assertaction(results[3], b'runcommand')
         self.assertEqual(results[3][1], {
-            'requestid': 1,
-            'command': b'mycommand',
-            'args': {},
-            'data': b'data1data2data3',
+            b'requestid': 1,
+            b'command': b'mycommand',
+            b'args': {},
+            b'data': b'data1data2data3',
         })
 
     def testargumentanddata(self):
@@ -150,42 +150,42 @@ 
         reactor = makereactor()
         results = list(sendframes(reactor, frames))
 
-        self.assertaction(results[-1], 'runcommand')
+        self.assertaction(results[-1], b'runcommand')
         self.assertEqual(results[-1][1], {
-            'requestid': 1,
-            'command': b'command',
-            'args': {
+            b'requestid': 1,
+            b'command': b'command',
+            b'args': {
                 b'key': b'val',
                 b'foo': b'bar',
             },
-            'data': b'value1value2',
+            b'data': b'value1value2',
         })
 
     def testnewandcontinuation(self):
         result = self._sendsingleframe(makereactor(),
             ffs(b'1 1 stream-begin command-request new|continuation '))
-        self.assertaction(result, 'error')
+        self.assertaction(result, b'error')
         self.assertEqual(result[1], {
-            'message': b'received command request frame with both new and '
-                       b'continuation flags set',
+            b'message': b'received command request frame with both new and '
+                        b'continuation flags set',
         })
 
     def testneithernewnorcontinuation(self):
         result = self._sendsingleframe(makereactor(),
             ffs(b'1 1 stream-begin command-request 0 '))
-        self.assertaction(result, 'error')
+        self.assertaction(result, b'error')
         self.assertEqual(result[1], {
-            'message': b'received command request frame with neither new nor '
-                       b'continuation flags set',
+            b'message': b'received command request frame with neither new nor '
+                        b'continuation flags set',
         })
 
     def testunexpectedcommanddata(self):
         """Command data frame when not running a command is an error."""
         result = self._sendsingleframe(makereactor(),
             ffs(b'1 1 stream-begin command-data 0 ignored'))
-        self.assertaction(result, 'error')
+        self.assertaction(result, b'error')
         self.assertEqual(result[1], {
-            'message': b'expected command request frame; got 3',
+            b'message': b'expected command request frame; got 3',
         })
 
     def testunexpectedcommanddatareceiving(self):
@@ -196,11 +196,11 @@ 
             ffs(b'1 1 0 command-data eos ignored'),
         ]))
 
-        self.assertaction(results[0], 'wantframe')
-        self.assertaction(results[1], 'error')
+        self.assertaction(results[0], b'wantframe')
+        self.assertaction(results[1], b'error')
         self.assertEqual(results[1][1], {
-            'message': b'received command data frame for request that is not '
-                       b'expecting data: 1',
+            b'message': b'received command data frame for request that is not '
+                        b'expecting data: 1',
         })
 
     def testconflictingrequestidallowed(self):
@@ -212,28 +212,28 @@ 
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
         result = reactor.onbytesresponseready(outstream, 1, b'response1')
-        self.assertaction(result, 'sendframes')
-        list(result[1]['framegen'])
+        self.assertaction(result, b'sendframes')
+        list(result[1][b'framegen'])
         results.append(self._sendsingleframe(
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
         result = reactor.onbytesresponseready(outstream, 1, b'response2')
-        self.assertaction(result, 'sendframes')
-        list(result[1]['framegen'])
+        self.assertaction(result, b'sendframes')
+        list(result[1][b'framegen'])
         results.append(self._sendsingleframe(
             reactor, ffs(b'1 1 stream-begin command-request new '
                          b"cbor:{b'name': b'command'}")))
         result = reactor.onbytesresponseready(outstream, 1, b'response3')
-        self.assertaction(result, 'sendframes')
-        list(result[1]['framegen'])
+        self.assertaction(result, b'sendframes')
+        list(result[1][b'framegen'])
 
         for i in range(3):
-            self.assertaction(results[i], 'runcommand')
+            self.assertaction(results[i], b'runcommand')
             self.assertEqual(results[i][1], {
-                'requestid': 1,
-                'command': b'command',
-                'args': {},
-                'data': None,
+                b'requestid': 1,
+                b'command': b'command',
+                b'args': {},
+                b'data': None,
             })
 
     def testconflictingrequestid(self):
@@ -245,10 +245,10 @@ 
                 b"cbor:{b'name': b'command1'}"),
         ]))
 
-        self.assertaction(results[0], 'wantframe')
-        self.assertaction(results[1], 'error')
+        self.assertaction(results[0], b'wantframe')
+        self.assertaction(results[1], b'error')
         self.assertEqual(results[1][1], {
-            'message': b'request with ID 1 already received',
+            b'message': b'request with ID 1 already received',
         })
 
     def testinterleavedcommands(self):
@@ -277,25 +277,25 @@ 
         ]))
 
         self.assertEqual([t[0] for t in results], [
-            'wantframe',
-            'wantframe',
-            'wantframe',
-            'wantframe',
-            'runcommand',
-            'runcommand',
+            b'wantframe',
+            b'wantframe',
+            b'wantframe',
+            b'wantframe',
+            b'runcommand',
+            b'runcommand',
         ])
 
         self.assertEqual(results[4][1], {
-            'requestid': 3,
-            'command': 'command3',
-            'args': {b'biz': b'baz', b'key': b'val'},
-            'data': None,
+            b'requestid': 3,
+            b'command': b'command3',
+            b'args': {b'biz': b'baz', b'key': b'val'},
+            b'data': None,
         })
         self.assertEqual(results[5][1], {
-            'requestid': 1,
-            'command': 'command1',
-            'args': {b'foo': b'bar', b'key1': b'val'},
-            'data': None,
+            b'requestid': 1,
+            b'command': b'command1',
+            b'args': {b'foo': b'bar', b'key1': b'val'},
+            b'data': None,
         })
 
     def testmissingcommanddataframe(self):
@@ -309,8 +309,8 @@ 
         ]
         results = list(sendframes(makereactor(), frames))
         self.assertEqual(len(results), 2)
-        self.assertaction(results[0], 'wantframe')
-        self.assertaction(results[1], 'runcommand')
+        self.assertaction(results[0], b'wantframe')
+        self.assertaction(results[1], b'runcommand')
 
     def testmissingcommanddataframeflags(self):
         frames = [
@@ -320,10 +320,10 @@ 
         ]
         results = list(sendframes(makereactor(), frames))
         self.assertEqual(len(results), 2)
-        self.assertaction(results[0], 'wantframe')
-        self.assertaction(results[1], 'error')
+        self.assertaction(results[0], b'wantframe')
+        self.assertaction(results[1], b'error')
         self.assertEqual(results[1][1], {
-            'message': b'command data frame without flags',
+            b'message': b'command data frame without flags',
         })
 
     def testframefornonreceivingrequest(self):
@@ -335,9 +335,9 @@ 
                 b"cbor:{b'name': b'command3'}"),
             ffs(b'5 1 0 command-data eos ignored'),
         ]))
-        self.assertaction(results[2], 'error')
+        self.assertaction(results[2], b'error')
         self.assertEqual(results[2][1], {
-            'message': b'received frame for request that is not receiving: 5',
+            b'message': b'received frame for request that is not receiving: 5',
         })
 
     def testsimpleresponse(self):
@@ -348,8 +348,8 @@ 
 
         outstream = reactor.makeoutputstream()
         result = reactor.onbytesresponseready(outstream, 1, b'response')
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin bytes-response eos response',
         ])
 
@@ -364,8 +364,8 @@ 
 
         outstream = reactor.makeoutputstream()
         result = reactor.onbytesresponseready(outstream, 1, first + second)
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin bytes-response continuation %s' % first,
             b'1 2 0 bytes-response eos %s' % second,
         ])
@@ -377,8 +377,8 @@ 
 
         outstream = reactor.makeoutputstream()
         result = reactor.onapplicationerror(outstream, 1, b'some message')
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin error-response application some message',
         ])
 
@@ -389,14 +389,14 @@ 
         results = list(sendcommandframes(reactor, instream, 1, b'mycommand',
                                          {}))
         self.assertEqual(len(results), 1)
-        self.assertaction(results[0], 'runcommand')
+        self.assertaction(results[0], b'runcommand')
 
         outstream = reactor.makeoutputstream()
         result = reactor.onbytesresponseready(outstream, 1, b'response')
-        self.assertaction(result, 'noop')
+        self.assertaction(result, b'noop')
         result = reactor.oninputeof()
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin bytes-response eos response',
         ])
 
@@ -408,12 +408,12 @@ 
 
         outstream = reactor.makeoutputstream()
         result = reactor.onbytesresponseready(outstream, 1, b'response1')
-        self.assertaction(result, 'noop')
+        self.assertaction(result, b'noop')
         result = reactor.onbytesresponseready(outstream, 3, b'response2')
-        self.assertaction(result, 'noop')
+        self.assertaction(result, b'noop')
         result = reactor.oninputeof()
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'1 2 stream-begin bytes-response eos response1',
             b'3 2 0 bytes-response eos response2'
         ])
@@ -432,8 +432,8 @@ 
         reactor.onbytesresponseready(outstream, 5, b'response5')
 
         result = reactor.oninputeof()
-        self.assertaction(result, 'sendframes')
-        self.assertframesequal(result[1]['framegen'], [
+        self.assertaction(result, b'sendframes')
+        self.assertframesequal(result[1][b'framegen'], [
             b'3 2 stream-begin bytes-response eos response3',
             b'1 2 0 bytes-response eos response1',
             b'5 2 0 bytes-response eos response5',
@@ -446,9 +446,9 @@ 
         list(sendcommandframes(reactor, stream, 1, b'command1', {}))
         results = list(sendcommandframes(reactor, stream, 1, b'command1', {}))
 
-        self.assertaction(results[0], 'error')
+        self.assertaction(results[0], b'error')
         self.assertEqual(results[0][1], {
-            'message': b'request with ID 1 is already active',
+            b'message': b'request with ID 1 is already active',
         })
 
     def testduplicaterequestonactivecommandnosend(self):
@@ -463,9 +463,9 @@ 
         # perspective of the reactor, the command is still active.
 
         results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
-        self.assertaction(results[0], 'error')
+        self.assertaction(results[0], b'error')
         self.assertEqual(results[0][1], {
-            'message': b'request with ID 1 is already active',
+            b'message': b'request with ID 1 is already active',
         })
 
     def testduplicaterequestaftersend(self):
@@ -475,10 +475,10 @@ 
         list(sendcommandframes(reactor, instream, 1, b'command1', {}))
         outstream = reactor.makeoutputstream()
         res = reactor.onbytesresponseready(outstream, 1, b'response')
-        list(res[1]['framegen'])
+        list(res[1][b'framegen'])
 
         results = list(sendcommandframes(reactor, instream, 1, b'command1', {}))
-        self.assertaction(results[0], 'runcommand')
+        self.assertaction(results[0], b'runcommand')
 
 if __name__ == '__main__':
     import silenttestrunner
diff --git a/tests/test-wireproto-clientreactor.py b/tests/test-wireproto-clientreactor.py
--- a/tests/test-wireproto-clientreactor.py
+++ b/tests/test-wireproto-clientreactor.py
@@ -28,16 +28,16 @@ 
         reactor = framing.clientreactor(hasmultiplesend=False, buffersends=True)
 
         request, action, meta = reactor.callcommand(b'foo', {})
-        self.assertEqual(request.state, 'pending')
-        self.assertEqual(action, 'noop')
+        self.assertEqual(request.state, b'pending')
+        self.assertEqual(action, b'noop')
 
         action, meta = reactor.flushcommands()
-        self.assertEqual(action, 'sendframes')
+        self.assertEqual(action, b'sendframes')
 
-        for frame in meta['framegen']:
-            self.assertEqual(request.state, 'sending')
+        for frame in meta[b'framegen']:
+            self.assertEqual(request.state, b'sending')
 
-        self.assertEqual(request.state, 'sent')
+        self.assertEqual(request.state, b'sent')
 
         with self.assertRaisesRegexp(error.ProgrammingError,
                                      'cannot issue new commands'):
@@ -54,51 +54,51 @@ 
 
         request, action, meta = reactor.callcommand(b'command1', {})
         self.assertEqual(request.requestid, 1)
-        self.assertEqual(action, 'sendframes')
+        self.assertEqual(action, b'sendframes')
 
-        self.assertEqual(request.state, 'pending')
+        self.assertEqual(request.state, b'pending')
 
-        for frame in meta['framegen']:
-            self.assertEqual(request.state, 'sending')
+        for frame in meta[b'framegen']:
+            self.assertEqual(request.state, b'sending')
 
-        self.assertEqual(request.state, 'sent')
+        self.assertEqual(request.state, b'sent')
 
         action, meta = reactor.flushcommands()
-        self.assertEqual(action, 'noop')
+        self.assertEqual(action, b'noop')
 
         # And we can send another command.
         request, action, meta = reactor.callcommand(b'command2', {})
         self.assertEqual(request.requestid, 3)
-        self.assertEqual(action, 'sendframes')
+        self.assertEqual(action, b'sendframes')
 
-        for frame in meta['framegen']:
-            self.assertEqual(request.state, 'sending')
+        for frame in meta[b'framegen']:
+            self.assertEqual(request.state, b'sending')
 
-        self.assertEqual(request.state, 'sent')
+        self.assertEqual(request.state, b'sent')
 
 class BadFrameRecvTests(unittest.TestCase):
     def testoddstream(self):
         reactor = framing.clientreactor()
 
         action, meta = sendframe(reactor, ffs(b'1 1 0 1 0 foo'))
-        self.assertEqual(action, 'error')
-        self.assertEqual(meta['message'],
-                         'received frame with odd numbered stream ID: 1')
+        self.assertEqual(action, b'error')
+        self.assertEqual(meta[b'message'],
+                         b'received frame with odd numbered stream ID: 1')
 
     def testunknownstream(self):
         reactor = framing.clientreactor()
 
         action, meta = sendframe(reactor, ffs(b'1 0 0 1 0 foo'))
-        self.assertEqual(action, 'error')
-        self.assertEqual(meta['message'],
-                         'received frame on unknown stream without beginning '
-                         'of stream flag set')
+        self.assertEqual(action, b'error')
+        self.assertEqual(meta[b'message'],
+                         b'received frame on unknown stream without beginning '
+                         b'of stream flag set')
 
     def testunhandledframetype(self):
         reactor = framing.clientreactor(buffersends=False)
 
         request, action, meta = reactor.callcommand(b'foo', {})
-        for frame in meta['framegen']:
+        for frame in meta[b'framegen']:
             pass
 
         with self.assertRaisesRegexp(error.ProgrammingError,
@@ -111,19 +111,19 @@ 
 
         request, action, meta = reactor.callcommand(b'foo', {})
 
-        self.assertEqual(action, 'sendframes')
-        for f in meta['framegen']:
+        self.assertEqual(action, b'sendframes')
+        for f in meta[b'framegen']:
             pass
 
         action, meta = sendframe(
             reactor,
             ffs(b'%d 0 stream-begin 4 0 foo' % request.requestid))
-        self.assertEqual(action, 'responsedata')
+        self.assertEqual(action, b'responsedata')
 
         action, meta = sendframe(
             reactor,
             ffs(b'%d 0 0 4 eos bar' % request.requestid))
-        self.assertEqual(action, 'responsedata')
+        self.assertEqual(action, b'responsedata')
 
 if __name__ == '__main__':
     import silenttestrunner
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -444,5 +444,7 @@ 
 test-verify.t
 test-websub.t
 test-win32text.t
+test-wireproto-clientreactor.py
 test-wireproto-framing.py
+test-wireproto-serverreactor.py
 test-xdg.t