Changeset 10494 for main/waeup.cas/trunk


Ignore:
Timestamp:
13 Aug 2013, 13:40:01 (11 years ago)
Author:
uli
Message:

Make everything work under Python3.x again.

Location:
main/waeup.cas/trunk/waeup/cas
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/server.py

    r10493 r10494  
    55import random
    66import time
    7 import urllib
    8 from urlparse import urlparse, parse_qsl, urlunparse
     7try:
     8    from urllib import urlencode        # Python 2.x
     9except ImportError:                     # pragma: no cover
     10    from urllib.parse import urlencode  # Python 3.x
     11try:
     12    from urlparse import urlparse, parse_qsl, urlunparse       # Python 2.x
     13except ImportError:                                     # pragma: no cover
     14    from urllib.parse import urlparse, parse_qsl, urlunparse  # Python 3.x
    915from webob import exc, Response
    1016from webob.dec import wsgify
     
    186192    old_params = dict(parse_qsl(parts[4]))
    187193    old_params.update(params_dict)
    188     query_string = urllib.urlencode(old_params)
     194    query_string = urlencode(old_params)
    189195    parts[4] = query_string
    190196    return urlunparse(parts)
  • main/waeup.cas/trunk/waeup/cas/tests/test_server.py

    r10492 r10494  
    55import unittest
    66from paste.deploy import loadapp
    7 from urlparse import parse_qsl
     7try:
     8    from urlparse import parse_qsl         # Python 2.x
     9except ImportError:                        # pragma: no cover
     10    from urllib.parse import parse_qsl     # Python 3.x
    811from webob import Request, Response
    912from webtest import TestApp as WebTestApp  # avoid py.test skip message
     
    569572        url = 'http://sample.com/index?a=1&b=2'
    570573        result1 = update_url('http://sample.com/index?a=1&b=2', dict(b='3'))
    571         assert result1 == 'http://sample.com/index?a=1&b=3'
     574        assert result1 in (
     575            'http://sample.com/index?a=1&b=3',
     576            'http://sample.com/index?b=3&a=1')
    572577        result2 = update_url('http://sample.com/index?b=2', dict(b='3'))
    573578        assert result2 == 'http://sample.com/index?b=3'
     
    575580        assert result3 == 'http://sample.com/index?b=3'
    576581        result4 = update_url('http://sample.com/index?a=2', dict(b='3'))
    577         assert result4 == 'http://sample.com/index?a=2&b=3'
     582        assert result4 in (
     583            'http://sample.com/index?a=2&b=3',
     584            'http://sample.com/index?b=3&a=2')
Note: See TracChangeset for help on using the changeset viewer.