Projet

Général

Profil

0002-trivial-use-urllib.parse-68784.patch

Frédéric Péters, 06 septembre 2022 19:23

Télécharger (2,06 ko)

Voir les différences:

Subject: [PATCH 2/5] trivial: use urllib.parse (#68784)

 fargo/utils.py       | 9 +++++----
 tests/test_public.py | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)
fargo/utils.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import urllib.parse
18

  
17 19
from django.utils.http import urlencode
18
from django.utils.six.moves.urllib import parse as urlparse
19 20

  
20 21

  
21 22
def make_url(__url, **kwargs):
22 23
    request = kwargs.pop('request', None)
23
    parsed = urlparse.urlparse(__url)
24
    query = urlparse.parse_qs(parsed.query)
24
    parsed = urllib.parse.urlparse(__url)
25
    query = urllib.parse.parse_qs(parsed.query)
25 26
    for key, value in kwargs.items():
26 27
        if value is not None:
27 28
            query[key] = value
28 29
    parsed = parsed[:4] + (urlencode(query),) + parsed[5:]
29
    url = urlparse.urlunparse(parsed)
30
    url = urllib.parse.urlunparse(parsed)
30 31
    if request:
31 32
        return request.build_absolute_uri(url)
32 33
    return url
tests/test_public.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17

  
18
import urllib.parse
19

  
18 20
import pytest
19 21
from django.test import override_settings
20 22
from django.urls import reverse
21
from django.utils.six.moves.urllib import parse as urlparse
22 23
from webtest import Upload
23 24

  
24 25
try:
......
34 35

  
35 36

  
36 37
def test_unlogged(app):
37
    assert urlparse.urlparse(app.get('/', status=302).location).path == '/login/'
38
    assert urllib.parse.urlparse(app.get('/', status=302).location).path == '/login/'
38 39

  
39 40

  
40 41
def test_upload(app, john_doe):
41
-