1
0
mirror of https://github.com/django/django.git synced 2025-03-10 01:12:53 +00:00
django/tests/forms_tests/tests/test_widgets.py
David Smith 097e3a70c1 Refs #33476 -- Applied Black's 2023 stable style.
Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.

https://github.com/psf/black/releases/tag/23.1.0
2023-02-01 11:04:38 +01:00

25 lines
880 B
Python

from django.contrib.admin.tests import AdminSeleniumTestCase
from django.test import override_settings
from django.urls import reverse
from ..models import Article
@override_settings(ROOT_URLCONF="forms_tests.urls")
class LiveWidgetTests(AdminSeleniumTestCase):
available_apps = ["forms_tests"] + AdminSeleniumTestCase.available_apps
def test_textarea_trailing_newlines(self):
"""
A roundtrip on a ModelForm doesn't alter the TextField value
"""
from selenium.webdriver.common.by import By
article = Article.objects.create(content="\nTst\n")
self.selenium.get(
self.live_server_url + reverse("article_form", args=[article.pk])
)
self.selenium.find_element(By.ID, "submit").click()
article = Article.objects.get(pk=article.pk)
self.assertEqual(article.content, "\r\nTst\r\n")