Permalink
Browse files

Merge pull request #10 from snbuback/master

Fix problem when using with gunicorn (django command)
  • Loading branch information...
2 parents d0d7d15 + 96c0e90 commit 86a044c628062bc2d6c4ed3feef5a94dc06a9fb9 @wandenberg wandenberg committed Mar 13, 2013
Showing with 7 additions and 2 deletions.
  1. +2 −2 simple_db_migrate/__init__.py
  2. +5 −0 tests/run_test.py
@@ -6,10 +6,10 @@
from config import FileConfig, Config
from main import Main
-SIMPLE_DB_MIGRATE_VERSION = '1.5.2'
+SIMPLE_DB_MIGRATE_VERSION = '1.5.3'
# fixing print in non-utf8 terminals
-if sys.stdout.encoding != 'UTF-8':
+if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding != 'UTF-8':
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
def run_from_argv(args=None):
View
@@ -41,6 +41,11 @@ def test_it_should_ensure_stdout_is_using_an_utf8_encoding(self, stdout_mock, co
codecs_mock.assert_called_with('utf-8')
self.assertEqual(new_stdout, sys.stdout)
+ @patch('sys.stdout', new_callable=object)
+ def test_it_should_not_break_when_sys_stdout_has_not_encoding_property(self, stdout_mock):
+ reload(simple_db_migrate)
+ self.assertIs(stdout_mock, sys.stdout)
+
def test_it_should_define_a_version_string(self):
self.assertTrue(isinstance(simple_db_migrate.SIMPLE_DB_MIGRATE_VERSION, str))

0 comments on commit 86a044c

Please sign in to comment.