Permalink
Browse files

Partial revert of 165f44a.

That commit didn't always improve readability.

See discussion on django-developers for details.
  • Loading branch information...
1 parent 222460a commit ee0ef1b0948c19bc5fee06a6b9b4286b879f81c1 @aaugustin aaugustin committed Sep 22, 2013
@@ -90,9 +90,9 @@ def test_l10n_intcomma(self):
'100', '1,000', '10,123', '10,311', '1,000,000', '1,234,567.1234567', '1,234,567.1234567',
None)
- with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=False), \
- translation.override('en'):
- self.humanize_tester(test_list, result_list, 'intcomma')
+ with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=False):
+ with translation.override('en'):
+ self.humanize_tester(test_list, result_list, 'intcomma')
def test_intcomma_without_number_grouping(self):
# Regression for #17414
@@ -116,18 +116,18 @@ def test_i18n_intcomma(self):
'100', '1000', '10123', '10311', '1000000', None)
result_list = ('100', '1.000', '10.123', '10.311', '1.000.000', '1.234.567,25',
'100', '1.000', '10.123', '10.311', '1.000.000', None)
- with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True), \
- translation.override('de'):
- self.humanize_tester(test_list, result_list, 'intcomma')
+ with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True):
+ with translation.override('de'):
+ self.humanize_tester(test_list, result_list, 'intcomma')
def test_i18n_intword(self):
test_list = ('100', '1000000', '1200000', '1290000',
'1000000000', '2000000000', '6000000000000')
result_list = ('100', '1,0 Million', '1,2 Millionen', '1,3 Millionen',
'1,0 Milliarde', '2,0 Milliarden', '6,0 Billionen')
- with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True), \
- translation.override('de'):
- self.humanize_tester(test_list, result_list, 'intword')
+ with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True):
+ with translation.override('de'):
+ self.humanize_tester(test_list, result_list, 'intword')
def test_apnumber(self):
test_list = [str(x) for x in range(1, 11)]
@@ -174,9 +174,9 @@ def test_naturalday_uses_localtime(self):
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
try:
- with override_settings(TIME_ZONE="America/Chicago", USE_TZ=True), \
- translation.override('en'):
- self.humanize_tester([dt], ['yesterday'], 'naturalday')
+ with override_settings(TIME_ZONE="America/Chicago", USE_TZ=True):
+ with translation.override('en'):
+ self.humanize_tester([dt], ['yesterday'], 'naturalday')
finally:
humanize.datetime = orig_humanize_datetime
View
@@ -745,11 +745,11 @@ def test_get_format_modules_lang(self):
self.assertEqual('.', get_format('DECIMAL_SEPARATOR', lang='en'))
def test_get_format_modules_stability(self):
- with self.settings(FORMAT_MODULE_PATH='i18n.other.locale'), \
- translation.override('de', deactivate=True):
- old = str("%r") % get_format_modules(reverse=True)
- new = str("%r") % get_format_modules(reverse=True) # second try
- self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
+ with self.settings(FORMAT_MODULE_PATH='i18n.other.locale'):
+ with translation.override('de', deactivate=True):
+ old = str("%r") % get_format_modules(reverse=True)
+ new = str("%r") % get_format_modules(reverse=True) # second try
+ self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
def test_localize_templatetag_and_filter(self):
"""
@@ -141,10 +141,12 @@ def test_reverse_object_does_not_exist_cache(self):
"""
p = Place(name='Zombie Cats', address='Not sure')
p.save()
- with self.assertNumQueries(1), self.assertRaises(Restaurant.DoesNotExist):
- p.restaurant
- with self.assertNumQueries(0), self.assertRaises(Restaurant.DoesNotExist):
- p.restaurant
+ with self.assertNumQueries(1):
+ with self.assertRaises(Restaurant.DoesNotExist):
+ p.restaurant
+ with self.assertNumQueries(0):
+ with self.assertRaises(Restaurant.DoesNotExist):
+ p.restaurant
def test_reverse_object_cached_when_related_is_accessed(self):
"""
@@ -197,8 +199,9 @@ def test_reverse_object_cached_when_related_is_unset(self):
self.assertEqual(self.p1.undergroundbar, b)
b.place = None
b.save()
- with self.assertNumQueries(0), self.assertRaises(UndergroundBar.DoesNotExist):
- self.p1.undergroundbar
+ with self.assertNumQueries(0):
+ with self.assertRaises(UndergroundBar.DoesNotExist):
+ self.p1.undergroundbar
def test_get_reverse_on_unsaved_object(self):
"""
@@ -210,21 +213,24 @@ def test_get_reverse_on_unsaved_object(self):
p = Place()
# When there's no instance of the origin of the one-to-one
- with self.assertNumQueries(0), self.assertRaises(UndergroundBar.DoesNotExist):
- p.undergroundbar
+ with self.assertNumQueries(0):
+ with self.assertRaises(UndergroundBar.DoesNotExist):
+ p.undergroundbar
UndergroundBar.objects.create()
# When there's one instance of the origin
# (p.undergroundbar used to return that instance)
- with self.assertNumQueries(0), self.assertRaises(UndergroundBar.DoesNotExist):
- p.undergroundbar
+ with self.assertNumQueries(0):
+ with self.assertRaises(UndergroundBar.DoesNotExist):
+ p.undergroundbar
UndergroundBar.objects.create()
# When there are several instances of the origin
- with self.assertNumQueries(0), self.assertRaises(UndergroundBar.DoesNotExist):
- p.undergroundbar
+ with self.assertNumQueries(0):
+ with self.assertRaises(UndergroundBar.DoesNotExist):
+ p.undergroundbar
def test_set_reverse_on_unsaved_object(self):
"""
@@ -233,8 +239,9 @@ def test_set_reverse_on_unsaved_object(self):
"""
p = Place()
b = UndergroundBar.objects.create()
- with self.assertNumQueries(0), self.assertRaises(ValueError):
- p.undergroundbar = b
+ with self.assertNumQueries(0):
+ with self.assertRaises(ValueError):
+ p.undergroundbar = b
def test_nullable_o2o_delete(self):
u = UndergroundBar.objects.create(place=self.p1)
View
@@ -152,8 +152,9 @@ def test_nested(self):
self.assertEqual(2, len(captured_queries))
def test_failure(self):
- with self.assertRaises(TypeError), CaptureQueriesContext(connection):
- raise TypeError
+ with self.assertRaises(TypeError):
+ with CaptureQueriesContext(connection):
+ raise TypeError
def test_with_client(self):
with CaptureQueriesContext(connection) as captured_queries:
@@ -189,12 +190,14 @@ def test_simple(self):
Person.objects.count()
def test_failure(self):
- with self.assertRaises(AssertionError) as exc_info, self.assertNumQueries(2):
- Person.objects.count()
+ with self.assertRaises(AssertionError) as exc_info:
+ with self.assertNumQueries(2):
+ Person.objects.count()
self.assertIn("1 queries executed, 2 expected", str(exc_info.exception))
- with self.assertRaises(TypeError), self.assertNumQueries(4000):
- raise TypeError
+ with self.assertRaises(TypeError):
+ with self.assertNumQueries(4000):
+ raise TypeError
def test_with_client(self):
person = Person.objects.create(name="test")
@@ -229,13 +232,13 @@ def test_usage(self):
render_to_string('template_used/base.html')
def test_nested_usage(self):
- with self.assertTemplateUsed('template_used/base.html'), \
- self.assertTemplateUsed('template_used/include.html'):
- render_to_string('template_used/include.html')
+ with self.assertTemplateUsed('template_used/base.html'):
+ with self.assertTemplateUsed('template_used/include.html'):
+ render_to_string('template_used/include.html')
- with self.assertTemplateUsed('template_used/extends.html'), \
- self.assertTemplateUsed('template_used/base.html'):
- render_to_string('template_used/extends.html')
+ with self.assertTemplateUsed('template_used/extends.html'):
+ with self.assertTemplateUsed('template_used/base.html'):
+ render_to_string('template_used/extends.html')
with self.assertTemplateUsed('template_used/base.html'):
with self.assertTemplateUsed('template_used/alternative.html'):
@@ -255,34 +258,38 @@ def test_not_used(self):
pass
def test_error_message(self):
- with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html'), \
- self.assertTemplateUsed('template_used/base.html'):
- pass
+ with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html'):
+ with self.assertTemplateUsed('template_used/base.html'):
+ pass
- with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html'), \
- self.assertTemplateUsed(template_name='template_used/base.html'):
- pass
+ with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html'):
+ with self.assertTemplateUsed(template_name='template_used/base.html'):
+ pass
- with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html.*template_used/alternative\.html$'), \
- self.assertTemplateUsed('template_used/base.html'):
- render_to_string('template_used/alternative.html')
+ with six.assertRaisesRegex(self, AssertionError, r'^template_used/base\.html.*template_used/alternative\.html$'):
+ with self.assertTemplateUsed('template_used/base.html'):
+ render_to_string('template_used/alternative.html')
def test_failure(self):
- with self.assertRaises(TypeError), self.assertTemplateUsed():
- pass
+ with self.assertRaises(TypeError):
+ with self.assertTemplateUsed():
+ pass
- with self.assertRaises(AssertionError), self.assertTemplateUsed(''):
- pass
+ with self.assertRaises(AssertionError):
+ with self.assertTemplateUsed(''):
+ pass
- with self.assertRaises(AssertionError), self.assertTemplateUsed(''):
- render_to_string('template_used/base.html')
+ with self.assertRaises(AssertionError):
+ with self.assertTemplateUsed(''):
+ render_to_string('template_used/base.html')
- with self.assertRaises(AssertionError), self.assertTemplateUsed(template_name=''):
- pass
+ with self.assertRaises(AssertionError):
+ with self.assertTemplateUsed(template_name=''):
+ pass
- with self.assertRaises(AssertionError), \
- self.assertTemplateUsed('template_used/base.html'):
- render_to_string('template_used/alternative.html')
+ with self.assertRaises(AssertionError):
+ with self.assertTemplateUsed('template_used/base.html'):
+ render_to_string('template_used/alternative.html')
class HTMLEqualTests(TestCase):
Oops, something went wrong.

0 comments on commit ee0ef1b

Please sign in to comment.