-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle non-ascii characters in platform version shown in Versions panel.
Non-ascii characters in platform name, for example Fedora's <<Schrödinger’s Cat>> causes VersionDebugPanel to fail with UnicodeDecodeError. Added compat.text_(.., 'utf8') convertion and moved platform name discovery to helper method to be easily swaped in unit tests.
- Loading branch information
Showing
2 changed files
with
45 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Unittests for DebugPanels.""" | ||
|
||
import unittest | ||
|
||
from pyramid_debugtoolbar.compat import PY3, text_type | ||
from pyramid import testing | ||
|
||
|
||
class TestVersionDebugPanel(unittest.TestCase): | ||
|
||
def _make_one(self): | ||
from pyramid_debugtoolbar.panels.versions import VersionDebugPanel | ||
request = testing.DummyRequest() | ||
return VersionDebugPanel(request) | ||
|
||
def test_it_with_nonascii_platform_name(self): | ||
panel = self._make_one() | ||
test_string = b'Schr\xc3\xb6dinger\xe2\x80\x99s_Cat' | ||
if PY3: | ||
# it's unicode string in py3 | ||
test_string = test_string.decode('utf8') | ||
|
||
panel._get_platform_name = lambda: test_string | ||
|
||
platform = panel.properties['platform'] | ||
self.assertTrue(isinstance(platform, text_type)) |