Author: cito
Date: Fri Nov 20 10:43:56 2015
New Revision: 558
Log:
Instance print function doesn't output to a pseudo-file
So for testing we have to use a real (temporary) file instead of StringIO.
Modified:
trunk/module/TEST_PyGreSQL_classic_connection.py
Modified: trunk/module/TEST_PyGreSQL_classic_connection.py
==============================================================================
--- trunk/module/TEST_PyGreSQL_classic_connection.py Fri Nov 20 10:23:56
2015 (r557)
+++ trunk/module/TEST_PyGreSQL_classic_connection.py Fri Nov 20 10:43:56
2015 (r558)
@@ -21,6 +21,7 @@
import sys
import threading
import time
+import tempfile
import pg # the module under test
@@ -28,8 +29,6 @@
from collections import namedtuple
-from StringIO import StringIO
-
# We need a database to test against. If LOCAL_PyGreSQL.py exists we will
# get our information from that. Otherwise we use the defaults.
dbname = 'unittest'
@@ -473,16 +472,17 @@
q = ("select 1 as a, 'hello' as h, 'w' as world"
" union select 2, 'xyz', 'uvw'")
r = self.c.query(q)
- s = StringIO()
- stdout, sys.stdout = sys.stdout, s
+ f = tempfile.TemporaryFile()
+ stdout, sys.stdout = sys.stdout, f
try:
print(r)
except Exception:
pass
finally:
sys.stdout = stdout
- r = s.getvalue()
- s.close()
+ f.seek(0)
+ r = f.read()
+ f.close()
self.assertEqual(r,
'a| h |world\n'
'-+-----+-----\n'
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql