Browse Source

flake8

master
Michael van Tellingen 8 years ago
parent
commit
aafcc8a901
No account linked to committer's email address
52 changed files with 135 additions and 142 deletions
  1. 2
    2
      setup.cfg
  2. 1
    1
      tests/_site/apps/customer/models.py
  3. 1
    1
      tests/_site/apps/myapp/models.py
  4. 1
    1
      tests/_site/apps/partner/models.py
  5. 1
    1
      tests/_site/apps/shipping/methods.py
  6. 2
    1
      tests/_site/myauth/models.py
  7. 1
    1
      tests/_site/shipping/methods.py
  8. 0
    11
      tests/dynamic_fixtures.py
  9. 0
    1
      tests/functional/catalogue/review_tests.py
  10. 1
    0
      tests/functional/checkout/guest_checkout_tests.py
  11. 3
    4
      tests/functional/customer/alert_tests.py
  12. 1
    1
      tests/functional/customer/history_tests.py
  13. 1
    1
      tests/functional/customer/profile_tests.py
  14. 1
    1
      tests/functional/dashboard/catalogue_tests.py
  15. 3
    3
      tests/functional/dashboard/category_tests.py
  16. 3
    2
      tests/functional/dashboard/dashboard_tests.py
  17. 0
    1
      tests/functional/dashboard/order_tests.py
  18. 1
    2
      tests/functional/dashboard/product_tests.py
  19. 6
    5
      tests/functional/dashboard/promotion_tests.py
  20. 0
    1
      tests/integration/address/form_tests.py
  21. 2
    1
      tests/integration/auth_tests.py
  22. 0
    1
      tests/integration/basket/model_tests.py
  23. 0
    1
      tests/integration/basket/view_tests.py
  24. 2
    2
      tests/integration/catalogue/product_image_tests.py
  25. 1
    1
      tests/integration/dashboard/__init__.py
  26. 0
    3
      tests/integration/dashboard/nav_tests.py
  27. 0
    1
      tests/integration/partner/test_dashboard_views.py
  28. 1
    1
      tests/integration/shipping/model_method_tests.py
  29. 1
    1
      tests/integration/shipping/scales_tests.py
  30. 1
    1
      tests/integration/templatetags/test_currency_filters.py
  31. 54
    38
      tests/unit/address/model_tests.py
  32. 1
    1
      tests/unit/basket/middleware_tests.py
  33. 1
    0
      tests/unit/catalogue/test_product_search_handler_setting.py
  34. 0
    1
      tests/unit/checkout/calculator_tests.py
  35. 0
    1
      tests/unit/checkout/forms_tests.py
  36. 0
    1
      tests/unit/core/autoslugfield_tests.py
  37. 2
    2
      tests/unit/core/customisation_tests.py
  38. 3
    3
      tests/unit/core/loading_tests.py
  39. 2
    2
      tests/unit/core/phonenumber_tests.py
  40. 3
    3
      tests/unit/core/prices_tests.py
  41. 4
    2
      tests/unit/dashboard/order_form_tests.py
  42. 1
    1
      tests/unit/forms/widget_tests.py
  43. 1
    1
      tests/unit/logging_tests.py
  44. 0
    1
      tests/unit/offer/condition_tests.py
  45. 2
    5
      tests/unit/order/processing_tests.py
  46. 1
    1
      tests/unit/partner/model_tests.py
  47. 2
    2
      tests/unit/payment/bankcard_tests.py
  48. 10
    11
      tests/unit/payment/form_tests.py
  49. 0
    1
      tests/unit/promotion_tests.py
  50. 1
    0
      tests/unit/search/munger_tests.py
  51. 0
    1
      tests/unit/shipping/discount_tests.py
  52. 10
    10
      tests/unit/utils_tests.py

+ 2
- 2
setup.cfg View File

@@ -7,9 +7,9 @@ testpaths = tests/
7 7
 
8 8
 [flake8]
9 9
 exclude = migrations
10
-ignore = F405,W503
10
+ignore = F405,W503,E731
11 11
 max-complexity = 10
12
-max-line-length=99
12
+max-line-length=159  
13 13
 
14 14
 [isort]
15 15
 line_length = 79

+ 1
- 1
tests/_site/apps/customer/models.py View File

@@ -1 +1 @@
1
-from oscar.apps.customer.models import *
1
+from oscar.apps.customer.models import *  # noqa

+ 1
- 1
tests/_site/apps/myapp/models.py View File

@@ -1,2 +1,2 @@
1 1
 class Goat(object):
2
-    pass
2
+    pass

+ 1
- 1
tests/_site/apps/partner/models.py View File

@@ -8,4 +8,4 @@ class StockRecord(abstract_models.AbstractStockRecord):
8 8
     offer_name = models.CharField(max_length=128, null=True, blank=True)
9 9
 
10 10
 
11
-from oscar.apps.partner.models import *
11
+from oscar.apps.partner.models import *  # noqa

+ 1
- 1
tests/_site/apps/shipping/methods.py View File

@@ -1,2 +1,2 @@
1 1
 class Free(object):
2
-    pass
2
+    pass

+ 2
- 1
tests/_site/myauth/models.py View File

@@ -41,7 +41,8 @@ class User(AbstractUser):
41 41
     """
42 42
     Custom user based on Oscar's AbstractUser
43 43
     """
44
-    username = models.CharField(_('username'), max_length=30, unique=True,
44
+    username = models.CharField(
45
+        _('username'), max_length=30, unique=True,
45 46
         help_text=_('Required. 30 characters or fewer. Letters, numbers and '
46 47
                     '@/./+/-/_ characters'),
47 48
         validators=[

+ 1
- 1
tests/_site/shipping/methods.py View File

@@ -1,2 +1,2 @@
1 1
 class Free(object):
2
-    pass
2
+    pass

+ 0
- 11
tests/dynamic_fixtures.py View File

@@ -1,11 +0,0 @@
1
-from django_dynamic_fixture.ddf import DataFixture
2
-from django_dynamic_fixture.fixture_algorithms.sequential_fixture import \
3
-    SequentialDataFixture
4
-
5
-class OscarDynamicDataFixtureClass(SequentialDataFixture):
6
-    """
7
-    This is need to support Oscar's PhoneNumberField: it's a custom type, so we
8
-    must provide values for testing
9
-    """
10
-    def phonenumberfield_config(self, field, key):
11
-        return '+49 351 3296645'

+ 0
- 1
tests/functional/catalogue/review_tests.py View File

@@ -1,6 +1,5 @@
1 1
 from oscar.test.testcases import WebTestCase
2 2
 from oscar.test.factories import create_product, UserFactory
3
-from oscar.core.compat import get_user_model
4 3
 from oscar.apps.catalogue.reviews.signals import review_added
5 4
 from oscar.test.contextmanagers import mock_signal_receiver
6 5
 

+ 1
- 0
tests/functional/checkout/guest_checkout_tests.py View File

@@ -444,6 +444,7 @@ class TestPaymentDetailsWithPreview(CheckoutMixin, WebTestCase):
444 444
         form.action = reverse('checkout:payment-details')
445 445
         self.assertEqual(form.submit(status="*").status_code, http_client.BAD_REQUEST)
446 446
 
447
+
447 448
 @override_settings(OSCAR_ALLOW_ANON_CHECKOUT=True)
448 449
 class TestPlacingOrder(CheckoutMixin, WebTestCase):
449 450
     is_anonymous = True

+ 3
- 4
tests/functional/customer/alert_tests.py View File

@@ -39,16 +39,15 @@ class TestAUserWithAnActiveStockAlert(WebTest):
39 39
         self.assertEqual(1, len(alerts))
40 40
         alert = alerts[0]
41 41
         self.assertFalse(alert.is_cancelled)
42
-        self.app.get(reverse('customer:alerts-cancel-by-pk',
43
-                             kwargs={'pk': alert.pk}),
44
-                             user=self.user)
42
+        self.app.get(
43
+            reverse('customer:alerts-cancel-by-pk', kwargs={'pk': alert.pk}),
44
+            user=self.user)
45 45
 
46 46
         alerts = ProductAlert.objects.filter(user=self.user)
47 47
         self.assertEqual(1, len(alerts))
48 48
         alert = alerts[0]
49 49
         self.assertTrue(alert.is_cancelled)
50 50
 
51
-
52 51
     def test_gets_notified_when_it_is_back_in_stock(self):
53 52
         self.stockrecord.num_in_stock = 10
54 53
         self.stockrecord.save()

+ 1
- 1
tests/functional/customer/history_tests.py View File

@@ -5,7 +5,7 @@ from django.http import HttpRequest
5 5
 
6 6
 from oscar.test.factories import create_product
7 7
 from oscar.core.compat import get_user_model
8
-from oscar.apps.customer  import history
8
+from oscar.apps.customer import history
9 9
 from oscar.templatetags.history_tags import get_back_button
10 10
 
11 11
 

+ 1
- 1
tests/functional/customer/profile_tests.py View File

@@ -142,7 +142,7 @@ class TestASignedInUser(WebTestCase):
142 142
 
143 143
         order_history_page = self.app.get(
144 144
             reverse('customer:order', args=[self.order.number]),
145
-                    user=self.user)
145
+            user=self.user)
146 146
         form = order_history_page.forms['order_form_%d' % self.order.id]
147 147
         form.submit()
148 148
 

+ 1
- 1
tests/functional/dashboard/catalogue_tests.py View File

@@ -23,7 +23,7 @@ class TestCatalogueViews(WebTestCase):
23 23
                 reverse('dashboard:stock-alert-list')]
24 24
         for url in urls:
25 25
             self.assertIsOk(self.get(url))
26
-    
26
+
27 27
     def test_upc_filter(self):
28 28
         product1 = create_product(upc='123')
29 29
         product2 = create_product(upc='12')

+ 3
- 3
tests/functional/dashboard/category_tests.py View File

@@ -34,9 +34,9 @@ class TestCategoryDashboard(WebTestCase):
34 34
         form['_position'] = 'left'
35 35
         form['_ref_node_id'] = c.id
36 36
         response = form.submit()
37
-        self.assertRedirects(response,
38
-                             reverse('dashboard:catalogue-category-detail-list',
39
-                                    args=(b.pk,)))
37
+        self.assertRedirects(
38
+            response,
39
+            reverse('dashboard:catalogue-category-detail-list', args=(b.pk,)))
40 40
 
41 41
     def test_handles_invalid_form_gracefully(self):
42 42
         dashboard_index = self.app.get(reverse('dashboard:index'),

+ 3
- 2
tests/functional/dashboard/dashboard_tests.py View File

@@ -30,8 +30,9 @@ class TestDashboardIndexForStaffUser(WebTestCase):
30 30
     def test_includes_hourly_report_with_no_orders(self):
31 31
         report = IndexView().get_hourly_report()
32 32
         self.assertEqual(len(report), 3)
33
-        for i, j in zip(sorted(report.keys()),
34
-                ['max_revenue', 'order_total_hourly', 'y_range']):
33
+
34
+        keys = ['max_revenue', 'order_total_hourly', 'y_range']
35
+        for i, j in zip(sorted(report.keys()), keys):
35 36
             self.assertEqual(i, j)
36 37
 
37 38
         self.assertEqual(len(report['order_total_hourly']), 12)

+ 0
- 1
tests/functional/dashboard/order_tests.py View File

@@ -196,7 +196,6 @@ class TestOrderListSearch(WebTestCase):
196 196
         ),
197 197
     ]
198 198
 
199
-
200 199
     def test_search_filter_descriptions(self):
201 200
         SourceTypeFactory(name='Visa', code='visa')
202 201
         url = reverse('dashboard:order-list')

+ 1
- 2
tests/functional/dashboard/product_tests.py View File

@@ -82,8 +82,7 @@ class TestCreateParentProduct(ProductWebTest):
82 82
 
83 83
     def test_requires_a_category(self):
84 84
         response = self.submit(title="Nice T-Shirt")
85
-        self.assertContains(response,
86
-            "must have at least one category")
85
+        self.assertContains(response, "must have at least one category")
87 86
         self.assertEqual(Product.objects.count(), 0)
88 87
 
89 88
     def test_for_smoke(self):

+ 6
- 5
tests/functional/dashboard/promotion_tests.py View File

@@ -7,11 +7,12 @@ class ViewTests(WebTestCase):
7 7
     is_staff = True
8 8
 
9 9
     def test_pages_exist(self):
10
-        urls = [reverse('dashboard:promotion-list'),
11
-                reverse('dashboard:promotion-create-rawhtml'),
12
-                reverse('dashboard:promotion-create-singleproduct'),
13
-                reverse('dashboard:promotion-create-image'),
14
-               ]
10
+        urls = [
11
+            reverse('dashboard:promotion-list'),
12
+            reverse('dashboard:promotion-create-rawhtml'),
13
+            reverse('dashboard:promotion-create-singleproduct'),
14
+            reverse('dashboard:promotion-create-image'),
15
+        ]
15 16
         for url in urls:
16 17
             self.assertIsOk(self.get(url))
17 18
 

+ 0
- 1
tests/integration/address/form_tests.py View File

@@ -1,7 +1,6 @@
1 1
 from django.test import TestCase
2 2
 
3 3
 from oscar.apps.address import models, forms
4
-from oscar.core.compat import get_user_model
5 4
 from oscar.test.factories import UserFactory
6 5
 
7 6
 

+ 2
- 1
tests/integration/auth_tests.py View File

@@ -26,7 +26,8 @@ class TestEmailAuthBackend(TestCase):
26 26
             'user1', email, password=password)
27 27
 
28 28
         for email_variation in [
29
-            'Person@example.com', 'Person@EXAMPLE.COM', 'person@Example.com']:
29
+            'Person@example.com', 'Person@EXAMPLE.COM', 'person@Example.com'
30
+        ]:
30 31
             user = authenticate(username=email_variation, password=password)
31 32
             self.assertEqual(user, created_user)
32 33
 

+ 0
- 1
tests/integration/basket/model_tests.py View File

@@ -118,7 +118,6 @@ class TestANonEmptyBasket(TestCase):
118 118
                     return prices.Unavailable()
119 119
                 return super(UnavailableProductStrategy, self).pricing_policy(product, stockrecord)
120 120
 
121
-
122 121
         try:
123 122
             self.basket.strategy = UnavailableProductStrategy()
124 123
             self.assertEqual(self.basket.all_lines()[1].get_warning(), u"'D\xf9\uff4d\u03fb\u03d2 title' is no longer available")

+ 0
- 1
tests/integration/basket/view_tests.py View File

@@ -4,7 +4,6 @@ from django.utils import six
4 4
 
5 5
 from oscar.apps.basket import views
6 6
 from oscar.test.factories import BasketFactory, VoucherFactory
7
-from oscar.test.utils import RequestFactory
8 7
 
9 8
 
10 9
 class TestVoucherAddView(TestCase):

+ 2
- 2
tests/integration/catalogue/product_image_tests.py View File

@@ -7,8 +7,8 @@ class TestProductImages(TestCase):
7 7
 
8 8
     def test_images_are_in_consecutive_order(self):
9 9
         product = factories.create_product()
10
-        images = [factories.create_product_image(
11
-                  product=product, display_order=i) for i in range(4)]
10
+        for i in range(4):
11
+            factories.create_product_image(product=product, display_order=i)
12 12
 
13 13
         product.images.all()[2].delete()
14 14
 

+ 1
- 1
tests/integration/dashboard/__init__.py View File

@@ -1 +1 @@
1
-# -*- coding: utf-8 -*-
1
+# -*- coding: utf-8 -*-

+ 0
- 3
tests/integration/dashboard/nav_tests.py View File

@@ -25,6 +25,3 @@ class TestCategory(TestCase):
25 25
     def test_non_staff_user_has_empty_menu(self):
26 26
         menu = get_nodes(self.non_staff_user)
27 27
         self.assertEqual(menu, [])
28
-
29
-
30
-

+ 0
- 1
tests/integration/partner/test_dashboard_views.py View File

@@ -2,7 +2,6 @@ from django.contrib.auth.models import Permission
2 2
 from django.test import TestCase
3 3
 from django.contrib.contenttypes.models import ContentType
4 4
 
5
-from oscar.core.loading import get_model
6 5
 from oscar.test.factories import PartnerFactory, PermissionFactory, UserFactory
7 6
 from oscar.apps.dashboard.partners import views
8 7
 

+ 1
- 1
tests/integration/shipping/model_method_tests.py View File

@@ -55,7 +55,7 @@ class TestOrderAndItemCharges(TestCase):
55 55
 
56 56
         charge = self.method.calculate(basket)
57 57
 
58
-        self.assertEqual(D('5.00') + 7*D('1.00'), charge.incl_tax)
58
+        self.assertEqual(D('5.00') + 7 * D('1.00'), charge.incl_tax)
59 59
 
60 60
 
61 61
 class ZeroFreeThresholdTest(TestCase):

+ 1
- 1
tests/integration/shipping/scales_tests.py View File

@@ -55,7 +55,7 @@ class TestScales(TestCase):
55 55
             basket.add(product, quantity=quantity)
56 56
 
57 57
         scale = Scale(attribute_code='weight')
58
-        self.assertEqual(1*3 + 2*4, scale.weigh_basket(basket))
58
+        self.assertEqual(1 * 3 + 2 * 4, scale.weigh_basket(basket))
59 59
 
60 60
     def test_decimals(self):
61 61
         basket = factories.create_basket(empty=True)

+ 1
- 1
tests/integration/templatetags/test_currency_filters.py View File

@@ -39,4 +39,4 @@ class TestCurrencyFilter(TestCase):
39 39
         with translation.override(None, deactivate=True):
40 40
             self.template.render(template.Context({
41 41
                 'price': D('10.23'),
42
-            }))
42
+            }))

+ 54
- 38
tests/unit/address/model_tests.py View File

@@ -37,76 +37,86 @@ class TestUserAddress(TestCase):
37 37
         self.assertEqual("Barrington", a.salutation)
38 38
 
39 39
     def test_has_name_property(self):
40
-        a = factories.UserAddressFactory.build(country=self.country,
41
-                first_name='Barry',
42
-                last_name='Barrington',
43
-                user=self.user)
40
+        a = factories.UserAddressFactory.build(
41
+            country=self.country,
42
+            first_name='Barry',
43
+            last_name='Barrington',
44
+            user=self.user)
44 45
         self.assertEqual("Barry Barrington", a.name)
45 46
 
46 47
     def test_has_summary_property(self):
47 48
         c = factories.CountryFactory.build(name='')
48
-        a = factories.UserAddressFactory(country=c,
49
-                title='Dr',
50
-                first_name='Barry',
51
-                last_name='Barrington',
52
-                line1='1 King Road',
53
-                line4='London',
54
-                postcode='SW1 9RE')
55
-        self.assertEqual("Dr Barry Barrington, 1 King Road, London, SW1 9RE, UNITED KINGDOM",
56
-                          a.summary)
49
+        a = factories.UserAddressFactory(
50
+            country=c,
51
+            title='Dr',
52
+            first_name='Barry',
53
+            last_name='Barrington',
54
+            line1='1 King Road',
55
+            line4='London',
56
+            postcode='SW1 9RE')
57
+        self.assertEqual(
58
+            "Dr Barry Barrington, 1 King Road, London, SW1 9RE, UNITED KINGDOM",
59
+            a.summary)
57 60
 
58 61
     def test_summary_includes_country(self):
59 62
         c = factories.CountryFactory.build(name='UNITED KINGDOM')
60
-        a = factories.UserAddressFactory.build(country=c,
61
-                title='Dr',
62
-                first_name='Barry',
63
-                last_name='Barrington',
64
-                line1='1 King Road',
65
-                line4='London',
66
-                postcode='SW1 9RE',
67
-                user=self.user)
63
+        a = factories.UserAddressFactory.build(
64
+            country=c,
65
+            title='Dr',
66
+            first_name='Barry',
67
+            last_name='Barrington',
68
+            line1='1 King Road',
69
+            line4='London',
70
+            postcode='SW1 9RE',
71
+            user=self.user)
68 72
         self.assertEqual(
69 73
             "Dr Barry Barrington, 1 King Road, London, SW1 9RE, UNITED KINGDOM",
70 74
             a.summary)
71 75
 
72 76
     def test_can_be_hashed(self):
73
-        a = factories.UserAddressFactory.build(country=self.country,
77
+        a = factories.UserAddressFactory.build(
78
+            country=self.country,
74 79
             user=self.user)
75 80
         hash = a.generate_hash()
76 81
         self.assertTrue(hash is not None)
77 82
 
78 83
     def test_can_be_hashed_including_non_ascii(self):
79
-        a = factories.UserAddressFactory.build(first_name=u"\u0141ukasz Smith",
80
-                last_name=u'Smith',
81
-                line1=u"75 Smith Road",
82
-                postcode=u"n4 8ty",
83
-                country=self.country,
84
-                user=self.user)
84
+        a = factories.UserAddressFactory.build(
85
+            first_name=u"\u0141ukasz Smith",
86
+            last_name=u'Smith',
87
+            line1=u"75 Smith Road",
88
+            postcode=u"n4 8ty",
89
+            country=self.country,
90
+            user=self.user)
85 91
         hash = a.generate_hash()
86 92
         self.assertTrue(hash is not None)
87 93
 
88 94
     def test_strips_whitespace_in_name_property(self):
89
-        a = factories.UserAddressFactory.build(first_name='',
95
+        a = factories.UserAddressFactory.build(
96
+            first_name='',
90 97
             last_name='Barrington',
91 98
             country=self.country,
92 99
             user=self.user)
93 100
         self.assertEqual("Barrington", a.name)
94 101
 
95 102
     def test_uses_city_as_an_alias_of_line4(self):
96
-        a = factories.UserAddressFactory.build(line4='London',
103
+        a = factories.UserAddressFactory.build(
104
+            line4='London',
97 105
             country=self.country,
98 106
             user=self.user)
99 107
         self.assertEqual('London', a.city)
100 108
 
101 109
     def test_converts_postcode_to_uppercase_when_cleaning(self):
102
-        address = factories.UserAddressFactory.build(postcode="n4 8ty",
110
+        address = factories.UserAddressFactory.build(
111
+            postcode="n4 8ty",
103 112
             country=self.country,
104 113
             user=self.user)
105 114
         address.clean()
106 115
         self.assertEqual("N4 8TY", address.postcode)
107 116
 
108 117
     def test_strips_whitespace_when_cleaning(self):
109
-        a = factories.UserAddressFactory.build(line1="  75 Smith Road  ",
118
+        a = factories.UserAddressFactory.build(
119
+            line1="  75 Smith Road  ",
110 120
             postcode="  n4 8ty",
111 121
             country=self.country,
112 122
             user=self.user)
@@ -115,7 +125,8 @@ class TestUserAddress(TestCase):
115 125
         self.assertEqual("75 Smith Road", a.line1)
116 126
 
117 127
     def test_active_address_fields_skips_whitespace_only_fields(self):
118
-        a = factories.UserAddressFactory.build(first_name='   ',
128
+        a = factories.UserAddressFactory.build(
129
+            first_name='   ',
119 130
             last_name='Barrington',
120 131
             line1='  75 Smith Road  ',
121 132
             postcode='  n4 8ty',
@@ -126,12 +137,14 @@ class TestUserAddress(TestCase):
126 137
         self.assertEqual("Barrington", active_fields[0])
127 138
 
128 139
     def test_ignores_whitespace_when_hashing(self):
129
-        a1 = factories.UserAddressFactory.build(first_name='Terry',
140
+        a1 = factories.UserAddressFactory.build(
141
+            first_name='Terry',
130 142
             last_name='Barrington',
131 143
             country=self.country,
132 144
             user=self.user)
133 145
         a1.clean()
134
-        a2 = factories.UserAddressFactory.build(first_name='   Terry  ',
146
+        a2 = factories.UserAddressFactory.build(
147
+            first_name='   Terry  ',
135 148
             last_name='     Barrington',
136 149
             country=self.country,
137 150
             user=self.user)
@@ -139,7 +152,8 @@ class TestUserAddress(TestCase):
139 152
         self.assertEqual(a1.generate_hash(), a2.generate_hash())
140 153
 
141 154
     def test_populate_shipping_address_doesnt_set_id(self):
142
-        a = factories.UserAddressFactory.build(country=self.country,
155
+        a = factories.UserAddressFactory.build(
156
+            country=self.country,
143 157
             user=self.user)
144 158
         a.clean()
145 159
         sa = ShippingAddress()
@@ -147,7 +161,8 @@ class TestUserAddress(TestCase):
147 161
         self.assertIsNone(sa.id)
148 162
 
149 163
     def test_populated_shipping_address_has_same_summary_user_address(self):
150
-        a = factories.UserAddressFactory.build(country=self.country,
164
+        a = factories.UserAddressFactory.build(
165
+            country=self.country,
151 166
             user=self.user)
152 167
         a.clean()
153 168
         sa = ShippingAddress()
@@ -155,7 +170,8 @@ class TestUserAddress(TestCase):
155 170
         self.assertEqual(sa.summary, a.summary)
156 171
 
157 172
     def test_summary_is_property(self):
158
-        a = factories.UserAddressFactory.build(title='',
173
+        a = factories.UserAddressFactory.build(
174
+            title='',
159 175
             line4='',
160 176
             first_name=" Terry  ",
161 177
             last_name='Barrington',

+ 1
- 1
tests/unit/basket/middleware_tests.py View File

@@ -31,4 +31,4 @@ class TestBasketMiddleware(TestCase):
31 31
         cookie_basket = self.middleware.get_cookie_basket("oscar_open_basket", request, None)
32 32
 
33 33
         self.assertEqual(None, cookie_basket)
34
-        self.assertIn("oscar_open_basket", request.cookies_to_delete)
34
+        self.assertIn("oscar_open_basket", request.cookies_to_delete)

+ 1
- 0
tests/unit/catalogue/test_product_search_handler_setting.py View File

@@ -5,6 +5,7 @@ from oscar.apps.catalogue.search_handlers import (
5 5
     get_product_search_handler_class,
6 6
 )
7 7
 
8
+
8 9
 class TestSearchHandler(object):
9 10
     pass
10 11
 

+ 0
- 1
tests/unit/checkout/calculator_tests.py View File

@@ -4,7 +4,6 @@ from django.test import TestCase
4 4
 import mock
5 5
 
6 6
 from oscar.apps.checkout import calculators
7
-from oscar.apps.shipping import methods
8 7
 from oscar.core import prices
9 8
 
10 9
 

+ 0
- 1
tests/unit/checkout/forms_tests.py View File

@@ -66,4 +66,3 @@ class TestShippingAddressForm(TestCase):
66 66
 
67 67
         data['country'] = Country.objects.get(iso_3166_1_a2='GB').pk
68 68
         self.assertTrue(ShippingAddressForm(data).is_valid())
69
-

+ 0
- 1
tests/unit/core/autoslugfield_tests.py View File

@@ -225,4 +225,3 @@ class AutoSlugFieldTest(TestCase):
225 225
             else:
226 226
                 self.fail("Could not exec %r: %s" % (string.strip(), e))
227 227
         return l
228
-

+ 2
- 2
tests/unit/core/customisation_tests.py View File

@@ -57,7 +57,8 @@ class TestForkAppFunction(TestCase):
57 57
         for module, expected_string in [
58 58
             ('models', 'from oscar.apps.order.models import *'),
59 59
             ('admin', 'from oscar.apps.order.admin import *'),
60
-            ('config', 'OrderConfig')]:
60
+            ('config', 'OrderConfig')
61
+        ]:
61 62
             filepath = os.path.join(self.tmp_folder, 'order', '%s.py' % module)
62 63
             self.assertTrue(os.path.exists(filepath))
63 64
 
@@ -70,4 +71,3 @@ class TestForkAppFunction(TestCase):
70 71
             native_migration_path = os.path.join(
71 72
                 self.tmp_folder, app, 'migrations')
72 73
             self.assertEqual(has_models, os.path.exists(native_migration_path))
73
-

+ 3
- 3
tests/unit/core/loading_tests.py View File

@@ -133,8 +133,8 @@ class TestOverridingCoreApps(TestCase):
133 133
 
134 134
     def test_means_the_overriding_model_is_registered_first(self):
135 135
         klass = get_model('partner', 'StockRecord')
136
-        self.assertEqual('tests._site.apps.partner.models',
137
-                          klass.__module__)
136
+        self.assertEqual(
137
+            'tests._site.apps.partner.models', klass.__module__)
138 138
 
139 139
 
140 140
 class TestAppLabelsForModels(TestCase):
@@ -145,7 +145,7 @@ class TestAppLabelsForModels(TestCase):
145 145
         missing = []
146 146
         for model in models:
147 147
             # Ignore non-Oscar models
148
-            if not 'oscar' in repr(model):
148
+            if 'oscar' not in repr(model):
149 149
                 continue
150 150
             # Don't know how to get the actual model's Meta class. But if
151 151
             # the parent doesn't have a Meta class, it's doesn't have an

+ 2
- 2
tests/unit/core/phonenumber_tests.py View File

@@ -1,4 +1,4 @@
1
-#-*- coding: utf-8 -*-
1
+# -*- coding: utf-8 -*-
2 2
 from django.test.testcases import TestCase
3 3
 from django.db import models
4 4
 from django import forms
@@ -33,7 +33,7 @@ equal_number_strings = ['+44 113 8921113', '+441138921113']
33 33
 local_numbers = [
34 34
     ('GB', '01606 751 78'),
35 35
     ('DE', '0176/96842671'),
36
-    ]
36
+]
37 37
 invalid_numbers = ['+44 113 892111', ]
38 38
 
39 39
 

+ 3
- 3
tests/unit/core/prices_tests.py View File

@@ -19,10 +19,10 @@ class TestPriceObject(TestCase):
19 19
 
20 20
     def test_price_equals_reflexivity(self):
21 21
         for price in (
22
-            Price(currency='USD', excl_tax=D('10.00')), 
22
+            Price(currency='USD', excl_tax=D('10.00')),
23 23
             Price(currency='USD', excl_tax=D('10.00'), tax=D('2.00')),
24 24
             Price(currency='USD', excl_tax=D('10.00'), incl_tax=D('12.00')),
25
-            ):
25
+        ):
26 26
             self.assertEqual(price, price)
27 27
 
28 28
     def test_price_equals_formats(self):
@@ -34,7 +34,7 @@ class TestPriceObject(TestCase):
34 34
         price1 = Price(currency='EUR', excl_tax=D('10.00'), tax=D('2.00'))
35 35
         price2 = Price(currency='USD', excl_tax=D('10.00'), tax=D('2.00'))
36 36
         self.assertNotEqual(price1, price2)
37
-        
37
+
38 38
     def test_price_equals_transitivity(self):
39 39
         prices = (
40 40
             Price(currency='EUR', excl_tax=D('10.00'), tax=D('2.00')),

+ 4
- 2
tests/unit/dashboard/order_form_tests.py View File

@@ -9,8 +9,10 @@ from oscar.apps.dashboard.orders import forms
9 9
 class TestOrderStatsForm(TestCase):
10 10
 
11 11
     def test_returns_inclusive_date_filters(self):
12
-        data = {'date_from': '2012-08-03',
13
-                'date_to': '2012-08-03',}
12
+        data = {
13
+            'date_from': '2012-08-03',
14
+            'date_to': '2012-08-03'
15
+        }
14 16
         form = forms.OrderStatsForm(data)
15 17
         self.assertTrue(form.is_valid())
16 18
         filters = form.get_filters()

+ 1
- 1
tests/unit/forms/widget_tests.py View File

@@ -19,4 +19,4 @@ class TestWidgetsDatetimeFormat(TestCase):
19 19
             ('%H:%M', 'hh:ii'),
20 20
         )
21 21
         for format_, expected in format_testcases:
22
-            self.assertEqual(widgets.datetime_format_to_js_time_format(format_), expected)
22
+            self.assertEqual(widgets.datetime_format_to_js_time_format(format_), expected)

+ 1
- 1
tests/unit/logging_tests.py View File

@@ -22,4 +22,4 @@ class TestLogging(TestCase):
22 22
             record = LogRecord(
23 23
                 name=None, level=None, pathname='', lineno=0,
24 24
                 msg=string, args=None, exc_info=None)
25
-            self.assertEqual(formatter.format(record), expected)
25
+            self.assertEqual(formatter.format(record), expected)

+ 0
- 1
tests/unit/offer/condition_tests.py View File

@@ -54,4 +54,3 @@ class TestCustomCondition(TestCase):
54 54
     def test_is_satified_by_match(self):
55 55
         self.basket.owner = factories.UserFactory(first_name="Barry")
56 56
         self.assertTrue(self.offer.is_condition_satisfied(self.basket))
57
-

+ 2
- 5
tests/unit/order/processing_tests.py View File

@@ -6,8 +6,6 @@ import six
6 6
 
7 7
 from oscar.apps.order import processing
8 8
 from oscar.apps.order import exceptions
9
-from oscar.apps.order.models import Line
10
-from oscar.test.factories import create_order
11 9
 
12 10
 
13 11
 class TestValidatePaymentEvent(TestCase):
@@ -50,7 +48,6 @@ class TestValidatePaymentEvent(TestCase):
50 48
         order = mock.Mock()
51 49
         lines = None
52 50
         line_quantities = None
53
-        out = self.event_handler.validate_payment_event(order, 'payment',
54
-                                                  D('10.00'), lines,
55
-                                                  line_quantities)
51
+        out = self.event_handler.validate_payment_event(
52
+            order, 'payment', D('10.00'), lines, line_quantities)
56 53
         self.assertIsNone(out)

+ 1
- 1
tests/unit/partner/model_tests.py View File

@@ -25,7 +25,7 @@ class TestStockRecord(TestCase):
25 25
 
26 26
     def test_net_stock_level_with_allocation(self):
27 27
         self.stockrecord.allocate(5)
28
-        self.assertEqual(10-5, self.stockrecord.net_stock_level)
28
+        self.assertEqual(10 - 5, self.stockrecord.net_stock_level)
29 29
 
30 30
     def test_allocated_does_not_alter_num_in_stock(self):
31 31
         self.stockrecord.allocate(5)

+ 2
- 2
tests/unit/payment/bankcard_tests.py View File

@@ -30,11 +30,11 @@ class TestBankCardValidation(TestCase):
30 30
             for number in numbers:
31 31
                 sniffed_bankcard_type = bankcards.bankcard_type(number)
32 32
                 self.assertEqual(expected_bankcard_type, sniffed_bankcard_type)
33
-    
33
+
34 34
     def test_valid_numbers(self):
35 35
         for number in self.valid_numbers:
36 36
             self.assertTrue(bankcards.luhn(number))
37
-    
37
+
38 38
     def test_invalid_numbers(self):
39 39
         for number in self.invalid_numbers:
40 40
             self.assertFalse(bankcards.luhn(number))

+ 10
- 11
tests/unit/payment/form_tests.py View File

@@ -6,10 +6,11 @@ from django.forms import ValidationError
6 6
 
7 7
 
8 8
 from oscar.apps.payment import forms, models
9
- # types=[bankcards.VISA, bankcards.VISA_ELECTRON, bankcards.MASTERCARD,
10
- #               bankcards.AMEX, bankcards.MAESTRO, bankcards.DINERS_CLUB,
11
- #               bankcards.DISCOVER, bankcards.JCB, bankcards.CHINA_UNIONPAY,
12
- #               bankcards.SOLO, bankcards.LASER, bankcards.SWITCH]
9
+# types=[bankcards.VISA, bankcards.VISA_ELECTRON, bankcards.MASTERCARD,
10
+#               bankcards.AMEX, bankcards.MAESTRO, bankcards.DINERS_CLUB,
11
+#               bankcards.DISCOVER, bankcards.JCB, bankcards.CHINA_UNIONPAY,
12
+#               bankcards.SOLO, bankcards.LASER, bankcards.SWITCH]
13
+
13 14
 
14 15
 class TestBankcardNumberField(TestCase):
15 16
 
@@ -26,16 +27,15 @@ class TestBankcardNumberField(TestCase):
26 27
 
27 28
     def test_amex_accepted_when_allowed(self):
28 29
         # Number taken from http://www.darkcoding.net/credit-card-numbers/
29
-        self.field = forms.BankcardNumberField(types=['American Express',])
30
+        self.field = forms.BankcardNumberField(types=['American Express'])
30 31
         self.assertEqual(
31 32
             '348934265521923', self.field.clean('348934265521923'))
32 33
 
33 34
     def test_amex_rejected_when_disallowed(self):
34
-        self.field = forms.BankcardNumberField(types=['Visa',])
35
+        self.field = forms.BankcardNumberField(types=['Visa'])
35 36
         with self.assertRaises(ValidationError):
36 37
             self.field.clean('348934265521923')
37 38
 
38
-
39 39
     def test_raises_error_for_invalid_card_type(self):
40 40
         with self.assertRaises(ImproperlyConfigured):
41 41
             self.field = forms.BankcardNumberField(types=['American Express', 'Nonsense'])
@@ -98,8 +98,7 @@ class TestExpiryMonthField(TestCase):
98 98
 
99 99
     def test_defaults_to_current_month(self):
100 100
         today = datetime.date.today()
101
-        self.assertEqual(["%.2d" % today.month, today.year],
102
-                          self.field.initial)
101
+        self.assertEqual(["%.2d" % today.month, today.year], self.field.initial)
103 102
 
104 103
 
105 104
 class TestOptionalExpiryMonthField(TestExpiryMonthField):
@@ -134,8 +133,8 @@ class TestCCVField(TestCase):
134 133
         try:
135 134
             self.field.clean("asdf")
136 135
         except ValidationError as e:
137
-            self.assertEqual("Please enter a 3 or 4 digit number",
138
-                              e.messages[0])
136
+            self.assertEqual(
137
+                "Please enter a 3 or 4 digit number", e.messages[0])
139 138
 
140 139
 
141 140
 class TestValidBankcardForm(TestCase):

+ 0
- 1
tests/unit/promotion_tests.py View File

@@ -8,4 +8,3 @@ class PromotionTest(TestCase):
8 8
     def test_default_template_name(self):
9 9
         promotion = models.Image.objects.create(name="dummy banner")
10 10
         self.assertEqual('promotions/image.html', promotion.template_name())
11
-

+ 1
- 0
tests/unit/search/munger_tests.py View File

@@ -59,6 +59,7 @@ SEARCH_FACETS = {
59 59
     ]),
60 60
 }
61 61
 
62
+
62 63
 @override_settings(OSCAR_SEARCH_FACETS=SEARCH_FACETS)
63 64
 class TestFacetMunger(TestCase):
64 65
 

+ 0
- 1
tests/unit/shipping/discount_tests.py View File

@@ -65,4 +65,3 @@ class TestDiscountingMethodsWithTax(TestCase):
65 65
         basket = Basket()
66 66
         charge = self.method.calculate(basket)
67 67
         self.assertEqual(D('7.00'), charge.incl_tax)
68
-

+ 10
- 10
tests/unit/utils_tests.py View File

@@ -6,23 +6,23 @@ from oscar.core.utils import compose
6 6
 class TestComposeFunction(TestCase):
7 7
 
8 8
     def test_composes_two_single_arg_functions(self):
9
-        double = lambda x: 2*x
10
-        triple = lambda x: 3*x
9
+        double = lambda x: 2 * x
10
+        triple = lambda x: 3 * x
11 11
 
12 12
         f = compose(double, triple)
13
-        self.assertEqual(f(2), 2*2*3)
13
+        self.assertEqual(f(2), 2 * 2 * 3)
14 14
 
15 15
     def test_composes_three_single_arg_functions(self):
16
-        double = lambda x: 2*x
17
-        triple = lambda x: 3*x
18
-        quadruple = lambda x: 4*x
16
+        double = lambda x: 2 * x
17
+        triple = lambda x: 3 * x
18
+        quadruple = lambda x: 4 * x
19 19
 
20 20
         f = compose(double, triple, quadruple)
21
-        self.assertEqual(f(2), 2*2*3*4)
21
+        self.assertEqual(f(2), 2 * 2 * 3 * 4)
22 22
 
23 23
     def test_composes_two_multi_arg_functions(self):
24
-        double = lambda x, y: (2*x, 2*y)
25
-        triple = lambda x, y: (3*x, 3*y)
24
+        double = lambda x, y: (2 * x, 2 * y)
25
+        triple = lambda x, y: (3 * x, 3 * y)
26 26
 
27 27
         f = compose(double, triple)
28
-        self.assertEqual(f(2, 4), (2*2*3, 4*2*3))
28
+        self.assertEqual(f(2, 4), (2 * 2 * 3, 4 * 2 * 3))

Loading…
Cancel
Save