Commits

Gael Pasgrimaud committed 54da8a1

improve print_stderr. conf.py now read version from setup.py

Comments (0)

Files changed (5)

 # other places throughout the built documents.
 #
 # The full version, including alpha/beta/rc tags.
-version = release = '1.3.1'
+version = release = '1.3.2'
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
 
 # If false, no module index is generated.
 #latex_use_modindex = True
+
+from os import path
+pkg_dir = path.abspath(__file__).split('/docs')[0]
+setup = path.join(pkg_dir, 'setup.py')
+if path.isfile(setup):
+    for line_ in open(setup):
+        if line_.startswith("version"):
+            version = line_.split('=')[-1]
+            version = version.strip()
+            version = version.strip("'\"")
+            release = version
+            break
+del pkg_dir, setup, path
+
 News
 ====
 
-1.3.2 (Unreleased)
--------------------
+1.3.2
+-----
 
-* improve showbrowser. fixed `#23 <https://bitbucket.org/ianb/webtest/issue/23`_
+* improve showbrowser. fixed `#23 <https://bitbucket.org/ianb/webtest/issue/23>`_
+
+* print_stderr fail with unicode string on python2
 
 1.3.1
 -----
 import sys
 import os
 
-version = '1.3.1'
+version = '1.3.2'
 
 setup(name='WebTest',
       version=version,

tests/test_testing.py

+# -*- coding: utf-8 -*-
 import webtest
 from webtest.debugapp import debug_app
 from webtest.compat import to_bytes
+from webtest.compat import print_stderr
 from tests.compat import unittest
+from tests.compat import u
+
+
+def test_print_unicode():
+    print_stderr(u('°C'))
+
 
 class TestTesting(unittest.TestCase):
 

webtest/compat.py

     if PY3:
         exec('print(value, file=sys.stderr)')
     else:
-        exec('print >> sys.stderr, value')
+        if isinstance(value, text_type):
+            # not really clean but this must *never* fail
+            try:
+                value = value.encode('utf-8')
+            except:
+                value = repr(value)
+        sys.stderr.write(value)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.