Skip to content

Commit

Permalink
Merge branch '2401-unicode-remove-linebreaks' of https://github.com/b…
Browse files Browse the repository at this point in the history
…rew/ckan into brew-2401-unicode-remove-linebreaks
  • Loading branch information
amercader committed May 11, 2015
2 parents 5f882cb + bc53d5d commit c6d9333
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ckan/lib/helpers.py
Expand Up @@ -1832,7 +1832,7 @@ def resource_view_full_page(resource_view):

def remove_linebreaks(string):
'''Remove linebreaks from string to make it usable in JavaScript'''
return str(string).replace('\n', '')
return unicode(string).replace('\n', '')


def list_dict_filter(list_, search_field, output_field, value):
Expand Down
10 changes: 5 additions & 5 deletions ckan/tests/lib/test_helpers.py
Expand Up @@ -91,13 +91,13 @@ def test_remove_linebreaks_removes_linebreaks(self):
assert result.find('\n') == -1,\
'"remove_linebreaks" should remove line breaks'

def test_remove_linebreaks_casts_into_str(self):
class StringLike(str):
def test_remove_linebreaks_casts_into_unicode(self):
class UnicodeLike(unicode):
pass

test_string = StringLike('foo')
test_string = UnicodeLike('foo')
result = h.remove_linebreaks(test_string)

strType = ''.__class__
strType = u''.__class__
assert result.__class__ == strType,\
'"remove_linebreaks" casts into str()'
'"remove_linebreaks" casts into unicode()'

0 comments on commit c6d9333

Please sign in to comment.