Permalink
Browse files

Merge pull request #41 from paulproteus/feature/no_more_raw_calls_to_str

Stop calling str() when we expect we might emit Unicode
  • Loading branch information...
aldeka committed Jul 13, 2012
2 parents 3a47ea1 + 422317f commit 87154341dc566dca8750f706d39294231d853265
@@ -31,6 +31,7 @@
reverse,
StepCompletion,
)
+from mysite.base.unicode_sanity import utf8
from mysite.missions.diffpatch import views, controllers
class PatchSingleFileTests(TwillTests):
@@ -145,23 +146,23 @@ def test_not_single_file(self):
try:
controllers.DiffSingleFileMission.validate_patch(self.make_good_patch() * 2)
except controllers.IncorrectPatch, e:
- self.assert_('affects more than one file' in str(e))
+ self.assert_('affects more than one file' in utf8(e))
else:
self.fail('no exception raised')
#def test_does_not_apply_correctly(self):
# try:
# controllers.DiffSingleFileMission.validate_patch(self.make_wrong_src_patch())
# except controllers.IncorrectPatch, e:
- # self.assert_('will not apply' in str(e))
+ # self.assert_('will not apply' in utf8(e))
# else:
# self.fail('no exception raised')
def test_produces_wrong_file(self):
try:
controllers.DiffSingleFileMission.validate_patch(self.make_wrong_dest_patch())
except controllers.IncorrectPatch, e:
- self.assert_('does not have the correct contents' in str(e))
+ self.assert_('does not have the correct contents' in utf8(e))
else:
self.fail('no exception raised')
@@ -172,7 +173,7 @@ def test_backwards_diff(self):
try:
controllers.DiffSingleFileMission.validate_patch(self.make_swapped_patch())
except controllers.IncorrectPatch, e:
- self.assert_('order of files passed to diff was flipped' in str(e))
+ self.assert_('order of files passed to diff was flipped' in utf8(e))
else:
self.fail('no exception raised')
@@ -184,7 +185,7 @@ def test_remove_trailing_whitespace(self):
try:
controllers.DiffSingleFileMission.validate_patch(self.make_patch_without_trailing_whitespace())
except controllers.IncorrectPatch, e:
- self.assert_('removed the space' in str(e))
+ self.assert_('removed the space' in utf8(e))
else:
self.fail('no exception raised')
@@ -196,7 +197,7 @@ def test_diff_missing_headers(self):
try:
controllers.DiffSingleFileMission.validate_patch("I lack headers.")
except controllers.IncorrectPatch, e:
- self.assert_('Make sure you are including the diff headers' in str(e))
+ self.assert_('Make sure you are including the diff headers' in utf8(e))
else:
self.fail('no exception raised')
@@ -362,7 +363,7 @@ def test_do_mission_incorrectly_revdiff(self):
# Submit, and see if we get the same error message we expect.
error = self.client.post(reverse(views.diffrecursive_submit), {'diff': diff})
- self.assert_('You submitted a patch that would revert the correct changes back to the originals. You may have mixed the parameters for diff, or performed a reverse patch.' in str(error))
+ self.assert_('You submitted a patch that would revert the correct changes back to the originals. You may have mixed the parameters for diff, or performed a reverse patch.' in utf8(error))
paulproteus = Person.objects.get(user__username='paulproteus')
self.assertEqual(len(StepCompletion.objects.filter(step__name='diffpatch_diffrecursive', person=paulproteus)), 0)
@@ -30,6 +30,7 @@
mission_completed,
set_mission_completed,
)
+from mysite.base.unicode_sanity import utf8
from mysite.missions.diffpatch import forms, controllers
### POST handlers
@@ -82,7 +83,7 @@ def diffsingle_submit(request):
set_mission_completed(request.user.get_profile(), 'diffpatch_diffsingle')
data['diffsingle_success'] = True
except controllers.IncorrectPatch, e:
- data['diffsingle_error_message'] = str(e)
+ data['diffsingle_error_message'] = utf8(e)
data['diffsingle_form'] = form
return single_file_diff(request, data)
@@ -104,7 +105,7 @@ def diffrecursive_submit(request):
set_mission_completed(request.user.get_profile(), 'diffpatch_diffrecursive')
data['diffrecursive_success'] = True
except controllers.IncorrectPatch, e:
- data['diffrecursive_error_message'] = str(e)
+ data['diffrecursive_error_message'] = utf8(e)
data['diffrecursive_form'] = form
return recursive_diff(request, data)
@@ -18,6 +18,7 @@
from django.core.management import BaseCommand, CommandError
from mysite.missions.svn import controllers
+from mysite.base.unicode_sanity import utf8
import sys
class Command(BaseCommand):
@@ -36,5 +37,5 @@ def handle(self, *args, **options):
try:
controllers.SvnCommitMission.pre_commit_hook(repo_path, txn_id)
except controllers.IncorrectPatch, e:
- sys.stderr.write('\n ' + str(e) + '\n\n')
+ sys.stderr.write('\n ' + utf8(e) + '\n\n')
raise CommandError, 'The commit failed to validate.'
@@ -19,6 +19,7 @@
from django.http import HttpResponse
+from mysite.base.unicode_sanity import utf8
from mysite.missions.base.views import *
from mysite.missions.tar import forms, controllers
@@ -54,7 +55,7 @@ def upload(request):
data['create_success'] = True
controllers.set_mission_completed(request.user.get_profile(), 'tar')
except controllers.IncorrectTarFile, e:
- data['what_was_wrong_with_the_tarball'] = str(e)
+ data['what_was_wrong_with_the_tarball'] = utf8(e)
data['create_form'] = form
return creating(request, data)

0 comments on commit 8715434

Please sign in to comment.