Commits

Alexander Artemenko  committed 0a18686

Add test for utf-8 output.

  • Participants
  • Parent commits 2cefed5

Comments (0)

Files changed (2)

 import os.path
 import inspect
 import code
+import codecs
 import types
 import traceback
 import subprocess
         self.history = []
         self.show_hidden_frames = False
         self.hidden_frames = []
+        self.stdout = codecs.getwriter('utf-8')(self.stdout)
 
     def _disable_pytest_capture_maybe(self):
         try:
     def format_source(self, src):
         if not self._init_pygments():
             return src
-        from pygments import highlight, lex
+        from pygments import highlight
         src = src.decode(self.config.encoding)
         return highlight(src, self._lexer, self._fmt)
 

File test/test_pdb.py

+# -*- coding: utf-8 -*-
 import inspect
 import os.path
 import sys
     disable_pytest_capturing = False
 
 
+class ConfigWithHighlight(ConfigTest):
+    highlight = True
+
+
 class PdbTest(pdb.Pdb):
     use_rawinput = 1
 
         s = s.replace(key, value)
     return s
 
-def check(func, expected):
+def run_func(func, expected):
+    """Runs given function and returns its output along with expected patterns.
+
+    It does not make any assertions. To compare func's output with expected
+    lines, use `check` function.
+    """
     expected = expected.strip().splitlines()
     commands = extract_commands(expected)
     expected = map(cook_regexp, expected)
-    lines = runpdb(func, commands)
+    return expected, runpdb(func, commands)
+
+def check(func, expected):
+    expected, lines = run_func(func, expected)
     assert len(expected) == len(lines)
     for pattern, string in zip(expected, lines):
         assert re.match(pattern, string)
 ... SyntaxError:
 # c
 """)
+
+def test_utf8():
+    def fn():
+        # тест
+        a = 1
+        set_trace(Config = ConfigWithHighlight)
+        return a
+
+    expected, lines = run_func(fn, '# ll\n# c')
+    assert 'тест' in lines[4]
+