Project

General

Profile

0002-Fixed-failing-tests-under-django-3.2-67945.patch

Agate Berriot, 04 August 2022 03:02 PM

Download (2.62 KB)

View differences:

Subject: [PATCH 2/2] Fixed failing tests under django 3.2 (#67945)

 tests/pricing/manager/test_agenda_pricing.py | 16 ++++++++++++++--
 tests/settings.py                            | 10 ++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
tests/pricing/manager/test_agenda_pricing.py
506 506
            adult_external_id='adult:1',
507 507
        )
508 508
    ]
509

  
510
    # XXX Compat: html entities are slightly different under django 2 and django 3
511
    # the following code ensure tests pass under both versions.
512
    # The output looks exactly the same to an end user.
509 513
    assert '<p>Pricing: 42.00</p>' in resp
510
    assert '<pre>{&#39;foo&#39;: &#39;bar&#39;, &#39;pricing&#39;: Decimal(&#39;42&#39;)}</pre>' in resp
514
    django2_match = (
515
        '<pre>{&#39;foo&#39;: &#39;bar&#39;, &#39;pricing&#39;: Decimal(&#39;42&#39;)}</pre>' in resp
516
    )
517
    django3_match = (
518
        '<pre>{&#x27;foo&#x27;: &#x27;bar&#x27;, &#x27;pricing&#x27;: Decimal(&#x27;42&#x27;)}</pre>' in resp
519
    )
520
    assert django2_match or django3_match
511 521

  
512 522
    mock_pricing_data.side_effect = PricingError(details={'foo': 'error'})
513 523
    resp = resp.form.submit().follow()
514 524
    assert 'Computed pricing data' in resp
515
    assert '<pre>{&#39;error&#39;: {&#39;foo&#39;: &#39;error&#39;}}</pre>' in resp
525
    django2_match = '<pre>{&#39;error&#39;: {&#39;foo&#39;: &#39;error&#39;}}</pre>' in resp
526
    django3_match = '<pre>{&#x27;error&#x27;: {&#x27;foo&#x27;: &#x27;error&#x27;}}</pre>' in resp
527
    assert django2_match or django3_match
516 528

  
517 529

  
518 530
@mock.patch('lingo.pricing.forms.get_event')
tests/settings.py
50 50
}
51 51

  
52 52
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
53
REST_FRAMEWORK = {
54
    'EXCEPTION_HANDLER': 'lingo.api.utils.exception_handler',
55
    # this is the default value but by explicitely setting it
56
    # we avoid a collision with django-webtest erasing the setting
57
    # while patching it
58
    'DEFAULT_AUTHENTICATION_CLASSES': [
59
        'rest_framework.authentication.SessionAuthentication',
60
        'rest_framework.authentication.BasicAuthentication',
61
    ],
62
}
53
-