Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor test to use less code

akjanik47e2188e828b
diff --git a/tests/test_checkout.py b/tests/test_checkout.py
index 7c63e69573..b7024b50c0 100644
--- a/tests/test_checkout.py
+++ b/tests/test_checkout.py
@@ -228,28 +228,15 @@ def test_checkout_create_order_insufficient_stock(
checkout.create_order()
-def test_note_form():
- checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
- form = NoteForm({'note': ''}, checkout=checkout)
- form.is_valid()
- form.set_checkout_note()
- assert checkout.note == ''
-
- form = NoteForm({'note': ' '}, checkout=checkout)
- form.is_valid()
- form.set_checkout_note()
- assert checkout.note == ''
-
- form = NoteForm({'note': ' test_note '}, checkout=checkout)
- form.is_valid()
- form.set_checkout_note()
- assert checkout.note == 'test_note'
-
[email protected]('note_value', [
+ '', ' ', ' test_note ','test_note'
+])
+def test_note_form(note_value):
checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
- form = NoteForm({'note': 'test_note'}, checkout=checkout)
+ form = NoteForm({'note': note_value}, checkout=checkout)
form.is_valid()
form.set_checkout_note()
- assert checkout.note == 'test_note'
+ assert checkout.note == note_value.strip()
def test_note_in_created_order(request_cart, customer_user, billing_address):