Skip to content

Commit

Permalink
Fix warning in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CleitonDeLima authored and codingjoe committed May 15, 2020
1 parent 3a19fa5 commit a47b531
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -285,11 +285,11 @@ def test_selected_option(self, db, genres):
widget_output = not_required_field.widget.render(
'primary_genre', genre.pk)
selected_option = '<option value="{pk}" selected="selected">{value}</option>'.format(
pk=genre.pk, value=force_text(genre))
pk=genre.pk, value=force_str(genre))
selected_option_a = '<option value="{pk}" selected>{value}</option>'.format(
pk=genre.pk, value=force_text(genre))
pk=genre.pk, value=force_str(genre))
unselected_option = '<option value="{pk}">{value}</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
Expand All @@ -304,8 +304,8 @@ def test_selected_option_label_from_instance(self, db, genres):

def get_selected_options(genre):
return '<option value="{pk}" selected="selected">{value}</option>'.format(
pk=genre.pk, value=force_text(genre)), '<option value="{pk}" selected>{value}</option>'.format(
pk=genre.pk, value=force_text(genre))
pk=genre.pk, value=force_str(genre)), '<option value="{pk}" selected>{value}</option>'.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()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions tests/testapp/forms.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit a47b531

Please sign in to comment.