source: ralphm-patches/py3-generic.patch @ 78:361e2111a663

Last change on this file since 78:361e2111a663 was 78:361e2111a663, checked in by Ralph Meijer <ralphm@…>, 6 years ago

Start port to Python 3.

File size: 3.0 KB
RevLine 
[78]1# HG changeset patch
2# Parent  4092375760243dbc2397107b9633729101590d49
3
4diff --git a/wokkel/generic.py b/wokkel/generic.py
5--- a/wokkel/generic.py
6+++ b/wokkel/generic.py
7@@ -7,6 +7,8 @@
8 Generic XMPP protocol helpers.
9 """
10 
11+from __future__ import division, absolute_import
12+
13 from zope.interface import implementer
14 
15 from twisted.internet import defer, protocol
16@@ -112,16 +114,16 @@
17 
18         iq.handled = True
19 
20-    def getDiscoInfo(self, requestor, target, node):
21+    def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
22         info = set()
23 
24-        if not node:
25+        if not nodeIdentifier:
26             from wokkel import disco
27             info.add(disco.DiscoFeature(NS_VERSION))
28 
29         return defer.succeed(info)
30 
31-    def getDiscoItems(self, requestor, target, node):
32+    def getDiscoItems(self, requestor, target, nodeIdentifier=''):
33         return defer.succeed([])
34 
35 
36diff --git a/wokkel/test/test_generic.py b/wokkel/test/test_generic.py
37--- a/wokkel/test/test_generic.py
38+++ b/wokkel/test/test_generic.py
39@@ -5,9 +5,14 @@
40 Tests for L{wokkel.generic}.
41 """
42 
43+from __future__ import division, absolute_import
44+
45 import re
46 
47+from zope.interface.verify import verifyObject
48+
49 from twisted.python import deprecate
50+from twisted.python.compat import unicode
51 from twisted.python.versions import Version
52 from twisted.trial import unittest
53 from twisted.trial.util import suppress as SUPPRESS
54@@ -15,6 +20,7 @@
55 from twisted.words.protocols.jabber.jid import JID
56 
57 from wokkel import generic
58+from wokkel.iwokkel import IDisco
59 from wokkel.test.helpers import XmlStreamStub
60 
61 NS_VERSION = 'jabber:iq:version'
62@@ -24,12 +30,22 @@
63     Tests for L{wokkel.generic.VersionHandler}.
64     """
65 
66+    def setUp(self):
67+        self.protocol = generic.VersionHandler('Test', '0.1.0')
68+
69+
70+    def test_interface(self):
71+        """
72+        L{generic.VersionHandler} implements {IDisco}.
73+        """
74+        verifyObject(IDisco, self.protocol)
75+
76+
77     def test_onVersion(self):
78         """
79         Test response to incoming version request.
80         """
81         self.stub = XmlStreamStub()
82-        self.protocol = generic.VersionHandler('Test', '0.1.0')
83         self.protocol.xmlstream = self.stub.xmlstream
84         self.protocol.send = self.stub.xmlstream.send
85         self.protocol.connectionInitialized()
86@@ -319,19 +335,10 @@
87         """
88         self.callDeprecated((Version("Wokkel", 0, 8, 0),
89                              "unicode.encode('idna')"),
90-                            generic.prepareIDNName, (b"example.com"))
91+                            generic.prepareIDNName, ("example.com"))
92     test_deprecated.suppress = []
93 
94 
95-    def test_bytestring(self):
96-        """
97-        An ASCII-encoded byte string is left as-is.
98-        """
99-        name = b"example.com"
100-        result = generic.prepareIDNName(name)
101-        self.assertEqual(b"example.com", result)
102-
103-
104     def test_unicode(self):
105         """
106         A unicode all-ASCII name is converted to an ASCII byte string.
Note: See TracBrowser for help on using the repository browser.