From a47b53134866006d3730561d24c081f19335b2e6 Mon Sep 17 00:00:00 2001 From: Cleiton Lima Date: Thu, 14 May 2020 14:10:06 -0300 Subject: [PATCH] Fix warning in tests --- tests/test_forms.py | 12 ++++++------ tests/test_views.py | 6 +++--- tests/testapp/forms.py | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_forms.py b/tests/test_forms.py index 69206b40..f994ae43 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -7,7 +7,7 @@ from django.db.models import QuerySet from django.urls import reverse from django.utils import translation -from django.utils.encoding import force_text +from django.utils.encoding import force_str from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions @@ -285,11 +285,11 @@ def test_selected_option(self, db, genres): widget_output = not_required_field.widget.render( 'primary_genre', genre.pk) selected_option = ''.format( - pk=genre.pk, value=force_text(genre)) + pk=genre.pk, value=force_str(genre)) selected_option_a = ''.format( - pk=genre.pk, value=force_text(genre)) + pk=genre.pk, value=force_str(genre)) unselected_option = ''.format( - pk=genre2.pk, value=force_text(genre2)) + pk=genre2.pk, value=force_str(genre2)) assert selected_option in widget_output or selected_option_a in widget_output, widget_output assert unselected_option not in widget_output @@ -304,8 +304,8 @@ def test_selected_option_label_from_instance(self, db, genres): def get_selected_options(genre): return ''.format( - pk=genre.pk, value=force_text(genre)), ''.format( - pk=genre.pk, value=force_text(genre)) + pk=genre.pk, value=force_str(genre)), ''.format( + pk=genre.pk, value=force_str(genre)) assert all(o not in widget_output for o in get_selected_options(genre)) genre.title = genre.title.upper() diff --git a/tests/test_views.py b/tests/test_views.py index a5b96aef..ba3b57b4 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,7 +1,7 @@ import json from django.core import signing -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str from django_select2.cache import cache from django_select2.forms import ModelSelect2Widget @@ -27,7 +27,7 @@ def test_get(self, client, artists): assert response.status_code == 200 data = json.loads(response.content.decode('utf-8')) assert data['results'] - assert {'id': artist.pk, 'text': smart_text(artist)} in data['results'] + assert {'id': artist.pk, 'text': smart_str(artist)} in data['results'] def test_no_field_id(self, client, artists): artist = artists[0] @@ -85,7 +85,7 @@ def test_label_from_instance(self, artists, client): data = json.loads(response.content.decode('utf-8')) assert data['results'] - assert {'id': artist.pk, 'text': smart_text(artist.title.upper())} in data['results'] + assert {'id': artist.pk, 'text': smart_str(artist.title.upper())} in data['results'] def test_url_check(self, client, artists): artist = artists[0] diff --git a/tests/testapp/forms.py b/tests/testapp/forms.py index 28c51d94..fb9388f8 100644 --- a/tests/testapp/forms.py +++ b/tests/testapp/forms.py @@ -1,5 +1,5 @@ from django import forms -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django_select2.forms import ( HeavySelect2MultipleWidget, HeavySelect2Widget, ModelSelect2MultipleWidget, @@ -39,7 +39,7 @@ class ArtistCustomTitleWidget(ModelSelect2Widget): ] def label_from_instance(self, obj): - return force_text(obj.title).upper() + return force_str(obj.title).upper() class GenreCustomTitleWidget(ModelSelect2Widget): @@ -49,7 +49,7 @@ class GenreCustomTitleWidget(ModelSelect2Widget): ] def label_from_instance(self, obj): - return force_text(obj.title).upper() + return force_str(obj.title).upper() class AlbumSelect2WidgetForm(forms.ModelForm):