Closed Bug 1585251 Opened 5 years ago Closed 4 years ago

[python3] Make unit tests pass in python3

Categories

(Webtools Graveyard :: Pontoon, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mathjazz, Assigned: jotes)

References

Details

Attachments

(6 files)

Upgrade to python3 is blocked by the unit tests failures. This bug will track fixes to unit tests needed to make them pass in the python3 environment.

In bug 1362323, :jotes kindly prepared the analysis of the current state of things:

There are 21 types of failures/errors that occur during a test-run on Python 3. Failures/errors sorted by number of occurrences:

118 times - TypeError: object of type 'map' has no len()
53 times - django.db.utils.DataError: invalid regular expression: quantifier operand invalid
14 times - TypeError: can only concatenate list (not "dict_values") to list
11 times - django.http.request.RawPostDataException: You cannot access body after reading from request's data stream
7 times - TypeError: 'dict_values' object is not subscriptable
5 times - TypeError: a bytes-like object is required, not 'str'
4 times - AttributeError: 'bytes' object has no attribute 'traceback'
3 times - TypeError: 'filter' object is not subscriptable
3 times - TypeError: '>=' not supported between instances of 'MagicMock' and 'int'
3 times - assert b'Bad Request: Request must be AJAX' == 'Bad Request: Request must be AJAX' + where b'Bad Request: Request must be AJAX' = <HttpResponseBadRequest status_code=400, "text/html; charset=utf-8">.content
2 times - TypeError: 'odict_values' object is not subscriptable
2 times - KeyError: 'has_next'
1 times - AssertionError: DoesNotExist not raised
1 times - TypeError: argument of type 'ResourceQuerySet' is not iterable
1 times - AssertionError: assert 'p' == 'cl' - p + cl
1 times - AssertionError: assert odict_keys(['...a', 'search']) == ['tag', 'type'...ta', 'search'] Use -v to get the full diff
1 times - ValueError: must have exactly one of create/read/write/append mode
1 times - TypeError: 'odict_items' object is not subscriptable
1 times - AssertionError: assert '^(?s:.)\Z' == '^.$' - ^(?s:.)\Z + ^.$
1 times - pontoon.base.models.DoesNotExist: Translation matching query does not exist.
1 times - TypeError: sequence item 0: expected str instance, bytes found

Detailed analysis of them per file:
https://gist.github.com/jotes/49c64b360ec29ee26efc6455a11fb853

There's a chance that some bigger problems/exceptions are hidden, but I don't think thats a blocker right now.

Blocks: 1362323
Blocks: 1585252
Attachment #9099458 - Attachment description: GitHub Pull Request → Link to GitHub pull-request: https://github.com/mozilla/pontoon/pull/1410
Assignee: m → poke
Depends on: 1591498
Attached file GitHub Pull Request

adngdb merged PR #1479: "Fix bug 1585251 - Fix last failing test with Python 3." in 1e8507b.

This is done! Huge thanks to @jotes who did most of the work, and to @Pike who took a stab at it recently too.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: