Projet

Général

Profil

Development #40012

Tourner les tests aussi en python3

Ajouté par Nicolas Roche il y a environ 4 ans. Mis à jour il y a environ 4 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
-
Version cible:
-
Début:
19 février 2020
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Non
Planning:
Non

Description

Dans l'optique de passer hobo en python3.


Demandes liées

Lié à Hobo - Development #40257: Tourner en python3Fermé28 février 2020

Actions

Révisions associées

Révision 5002ed10 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt tox.ini to run tests in python3 too (#40012)

Révision 932e6da8 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt coverage output repositories to tox target names (#40012)

Révision f128b00b (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt import StringIO to run tests in python3 (#40012)

Révision 70140e7b (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt import urlparse to run tests in python3 (#40012)

Révision 6da1e63a (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt import builtins to run tests in python3 (#40012)

Révision 825939d2 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

tests: adapt strings encoding to run tests in python3 (#40012)

Révision df83160f (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: convert dictionaries into a subscriptable array (#40012)

Révision 31a116cc (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace basestring by six.string_types (#40012)

Révision 517ef1d3 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: modify exception string (#40012)

Révision 9ef19058 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace unicode type to six.text_type (#40012)

Révision 926b32ed (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: accept byte content from django.template.response.TemplateResponse (#40012)

Révision 7ca962ba (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: update smtpd mock in tests (#40012)

Révision 012eba57 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace DjangoWebtestResponse body with text (#40012)

Révision df3dff15 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace DjangoWebtestResponse content with text (#40012)

Révision 980da6df (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: use bytes input for unicode strings with encoding declaration (#40012)

Révision 31101437 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: update json exceptions (#40012)

Révision e59369db (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: redo #36273 as bytes really wanted here (#40012)

Révision ae18a366 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: correct urllib import to use quote (#40012)

Révision 068ad2dd (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: adapt strings encoding (#40012)

Révision 53b81ec6 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace dict.iteritems() by items() (#40012)

Révision cf722374 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: decode HttpResponse content (#40012)

Révision d5cbe123 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: remove no longer needed call to byteify (#40012)

Révision 212b9ab7 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: replace json parser input with str (#40012)

Révision 2f66e250 (diff)
Ajouté par Nicolas Roche il y a environ 4 ans

python3: adapt worker agent (#40012)

Historique

#1

Mis à jour par Nicolas Roche il y a environ 4 ans

  • Statut changé de Nouveau à En cours

Plutôt que d'ajouter les 23 patchs, voici la branche : https://git.entrouvert.org/hobo.git/log/?h=wip/40012-run-python3-tests

J'ai l'impression d'être bloqué par authentic.

packages/authentic2_auth_fc/models.py", line 21, in <module>
    import urlparse
ImportError: No module named 'urlparse'
ERROR: InvocationError for command /tmp/tox-jenkins/hobo/wip/40012-run-python3-tests/py3-coverage-authentic/bin/py.test --junitxml=junit-py3-coverage-authentic.xml --cov-report xml --cov-report html --cov=hobo/ --cov-config .coveragerc tests_authentic/ (exited with code 1)

#2

Mis à jour par Frédéric Péters il y a environ 4 ans

authentic n'est pas encore migré vers python 3, en effet, ces erreurs doivent être ignorées, ou ces tests sautés, en attendant.

#3

Mis à jour par Nicolas Roche il y a environ 4 ans

La couverture est de 75% des lignes. Il manque :
  • agent.authentic2 role_forms.py
  • agent.worker (la partie celery)
  • contrib.ozwillo.management.commands (obsolète à ce que j'ai cru comprendre)
  • environment.management.commands check_operational.py
  • multitenant
  • multitenant.management.commands

Est-ce que j'essaye d'augmenter la couverture ?

#4

Mis à jour par Frédéric Péters il y a environ 4 ans

Pour moi ça sera déjà bien de pousser les bouts Python 3 (je vais relireà, étendre la couverture derrière et à cette occasion voi ce qui pétera.

#5

Mis à jour par Frédéric Péters il y a environ 4 ans

-                    computed_hmac = hmac.new(api_secret, request.body, sha1).hexdigest()
+                    computed_hmac = hmac.new(api_secret, request.text, sha1).hexdigest()

me surprend, hmac.new attend plutôt des bytes.

-                        if type(y) in (str, unicode, bool)])
+                        if type(y) in (str, six.text_type, bool)])

Dans les tests,

-    assert 'No suitable SPF record found' in response.content
+    assert 'No suitable SPF record found' in str(response.content)

Plutôt taper response.text que le str(). (mais je vois que ça utilise le test client django et pas webtest, donc je ne sais pas) (mais alors, force_text plutôt que str).

 whitelist_externals =
        /bin/mv
+        /usr/bin/mv

Je ne vois pas ce qui appelle mv. (mais il serait plutôt à mettre à jour pour faire /bin/mv, plutôt que modifier ici, je trouve).

#6

Mis à jour par Nicolas Roche il y a environ 4 ans

  • Statut changé de En cours à Solution proposée

J'ai tenu compte des remarques et modifié la branche en conséquence : https://git.entrouvert.org/hobo.git/log/?h=wip/40012-run-python3-tests

#7

Mis à jour par Frédéric Péters il y a environ 4 ans

  • python3: correct six import path (#40012)

Il faut rebaser et corriger le commit qui a introduit l'erreur, plutôt que taper un commit de correction par-dessus.

  • tests: adadapt import urlparse to run tests in python3 (#40012)

Corriger le message de commit.

python3: update smtpd mock in tests (#40012)

Ce commit contient +import six dans une occurence qui ne me semble pas reprise par python3: correct six import path; il faudrait la corriger et vérifier que d'autres n'existent pas.

#8

Mis à jour par Nicolas Roche il y a environ 4 ans

Remarques prises en compte (dans la branche mise à jour).

$ git grep '^import six'
(vide)

#9

Mis à jour par Nicolas Roche il y a environ 4 ans

#10

Mis à jour par Nicolas Roche il y a environ 4 ans

J'ai ajouté un dernier commit pour anticiper le test sur hobo/agent/worker/services.py ajouté par #40098
https://git.entrouvert.org/hobo.git/commit/?id=9fdf34e5a1067c67a94f3abf877b626f5ef248ac

#11

Mis à jour par Frédéric Péters il y a environ 4 ans

  • Statut changé de Solution proposée à Solution validée

Je serais pour envoyer tout ça.

#12

Mis à jour par Nicolas Roche il y a environ 4 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit 2f66e25022ec5c3c830a4b86b297fa50ac91a6d1
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Fri Feb 28 12:14:02 2020 +0100

    python3: adapt worker agent (#40012)

commit 212b9ab7364b92ab4eca6733adbf832680f1508f
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 20:39:09 2020 +0100

    python3: replace json parser input with str (#40012)

commit d5cbe123dfb05e140507e572fddfb2c25ccf36e4
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 14:46:16 2020 +0100

    python3: remove no longer needed call to byteify (#40012)

commit cf7223741361776134ae0f244c28cd3c8b862dca
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 14:06:50 2020 +0100

    python3: decode HttpResponse content (#40012)

commit 53b81ec6ab5c8625e6bb0aaa47f00395e20b810e
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 13:39:22 2020 +0100

    python3: replace dict.iteritems() by items() (#40012)

commit 068ad2dd721e4866d5c7e64ba239209827e470ee
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 16:13:39 2020 +0100

    python3: adapt strings encoding (#40012)

commit ae18a366c0c6cd11f65b5dd570431d76b4662ecb
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 12:06:28 2020 +0100

    python3: correct urllib import to use quote (#40012)

commit e59369db0bc880889679d117e8bec6776255c74c
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 15:28:36 2020 +0100

    python3: redo #36273 as bytes really wanted here (#40012)

commit 311014371e3bd0731ba4187245af5809b78d0a8a
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 11:37:41 2020 +0100

    python3: update json exceptions (#40012)

commit 980da6dfd040c1750eb1f1a877db8b08c95a75b0
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 15:17:12 2020 +0100

    python3: use bytes input for unicode strings with encoding declaration (#40012)

commit c80d6bf7642d2c633468073f103493c96a27c9b2
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 15:15:23 2020 +0100

    python3: pass bytes to hashlib.md5 (40012)

commit df3dff1532b98c36aae9ac034a2b7bcef456c58d
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 17:36:32 2020 +0100

    python3: replace DjangoWebtestResponse content with text (#40012)

commit 012eba57a035f3b9f2c8073868d0e9310c7fa7e4
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 17:30:51 2020 +0100

    python3: replace DjangoWebtestResponse body with text (#40012)

commit 7ca962ba6bb83b084fbe42fd79813efbed478945
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 17:26:57 2020 +0100

    python3: update smtpd mock in tests (#40012)

commit 926b32ed80ad7d8d2e2d7c0ea509ad47fbd4509f
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 16:44:22 2020 +0100

    python3: accept byte content from django.template.response.TemplateResponse (#40012)

commit 9ef19058c8377c8edf61ae45b57573796bc2e665
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 16:28:59 2020 +0100

    python3: replace unicode type to six.text_type (#40012)

commit 517ef1d3345a9131e80ef99236d289dece3ad498
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 16:26:49 2020 +0100

    python3: modify exception string (#40012)

commit 31a116ccc96a0fab2fb905a056662735110b5b70
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 16:24:07 2020 +0100

    python3: replace basestring by six.string_types (#40012)

commit df83160f7e5993a466f51ca5ee09b6a466019309
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 16:07:26 2020 +0100

    python3: convert dictionaries into a subscriptable array (#40012)

commit 825939d23b71165f508ede6a6d7722ab46356b82
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 14:09:21 2020 +0100

    tests: adapt strings encoding to run tests in python3 (#40012)

commit 6da1e63aab9c63235cb57d5668712efa77bb8344
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Wed Feb 19 13:21:38 2020 +0100

    tests: adapt import builtins to run tests in python3 (#40012)

commit 70140e7b38705d5d57aeb6c3fd4ddae5cb99348f
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Mon Feb 17 16:26:35 2020 +0100

    tests: adapt import urlparse to run tests in python3 (#40012)

commit f128b00b6183005cf22a19180b9bdf00c4128974
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Thu Feb 20 17:41:30 2020 +0100

    tests: adapt import StringIO to run tests in python3 (#40012)

commit 932e6da8f3a78eea2671bed6511bfddd74f15699
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Fri Feb 21 16:15:14 2020 +0100

    tests: adapt coverage output repositories to tox target names (#40012)

commit 5002ed100e95297b30089dc63ec219ea770864d2
Author: Nicolas ROCHE <nroche@entrouvert.com>
Date:   Mon Feb 17 15:24:37 2020 +0100

    tests: adapt tox.ini to run tests in python3 too (#40012)
#13

Mis à jour par Frédéric Péters il y a environ 4 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF