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
  • wokkel/generic.py

    # HG changeset patch
    # Parent  4092375760243dbc2397107b9633729101590d49
    
    diff --git a/wokkel/generic.py b/wokkel/generic.py
    a b  
    77Generic XMPP protocol helpers.
    88"""
    99
     10from __future__ import division, absolute_import
     11
    1012from zope.interface import implementer
    1113
    1214from twisted.internet import defer, protocol
     
    112114
    113115        iq.handled = True
    114116
    115     def getDiscoInfo(self, requestor, target, node):
     117    def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
    116118        info = set()
    117119
    118         if not node:
     120        if not nodeIdentifier:
    119121            from wokkel import disco
    120122            info.add(disco.DiscoFeature(NS_VERSION))
    121123
    122124        return defer.succeed(info)
    123125
    124     def getDiscoItems(self, requestor, target, node):
     126    def getDiscoItems(self, requestor, target, nodeIdentifier=''):
    125127        return defer.succeed([])
    126128
    127129
  • wokkel/test/test_generic.py

    diff --git a/wokkel/test/test_generic.py b/wokkel/test/test_generic.py
    a b  
    55Tests for L{wokkel.generic}.
    66"""
    77
     8from __future__ import division, absolute_import
     9
    810import re
    911
     12from zope.interface.verify import verifyObject
     13
    1014from twisted.python import deprecate
     15from twisted.python.compat import unicode
    1116from twisted.python.versions import Version
    1217from twisted.trial import unittest
    1318from twisted.trial.util import suppress as SUPPRESS
     
    1520from twisted.words.protocols.jabber.jid import JID
    1621
    1722from wokkel import generic
     23from wokkel.iwokkel import IDisco
    1824from wokkel.test.helpers import XmlStreamStub
    1925
    2026NS_VERSION = 'jabber:iq:version'
     
    2430    Tests for L{wokkel.generic.VersionHandler}.
    2531    """
    2632
     33    def setUp(self):
     34        self.protocol = generic.VersionHandler('Test', '0.1.0')
     35
     36
     37    def test_interface(self):
     38        """
     39        L{generic.VersionHandler} implements {IDisco}.
     40        """
     41        verifyObject(IDisco, self.protocol)
     42
     43
    2744    def test_onVersion(self):
    2845        """
    2946        Test response to incoming version request.
    3047        """
    3148        self.stub = XmlStreamStub()
    32         self.protocol = generic.VersionHandler('Test', '0.1.0')
    3349        self.protocol.xmlstream = self.stub.xmlstream
    3450        self.protocol.send = self.stub.xmlstream.send
    3551        self.protocol.connectionInitialized()
     
    319335        """
    320336        self.callDeprecated((Version("Wokkel", 0, 8, 0),
    321337                             "unicode.encode('idna')"),
    322                             generic.prepareIDNName, (b"example.com"))
     338                            generic.prepareIDNName, ("example.com"))
    323339    test_deprecated.suppress = []
    324340
    325341
    326     def test_bytestring(self):
    327         """
    328         An ASCII-encoded byte string is left as-is.
    329         """
    330         name = b"example.com"
    331         result = generic.prepareIDNName(name)
    332         self.assertEqual(b"example.com", result)
    333 
    334 
    335342    def test_unicode(self):
    336343        """
    337344        A unicode all-ASCII name is converted to an ASCII byte string.
Note: See TracBrowser for help on using the repository browser.