Skip to content

Commit b6b895c

Browse files
committed
add try/except to import StringIO for test_print function
1 parent 1f1610f commit b6b895c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/unit/test_help.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import io
21
import sys
32

43
from ..testcase import TestCase
54

5+
66
class TestHelp(TestCase):
77

88
def test_get_function_list(self):
@@ -26,7 +26,14 @@ def test_invalid_function_help(self):
2626
self.assertEqual(h, "Function 'fake' does not exist.")
2727

2828
def test_print(self):
29-
h = io.StringIO()
29+
30+
try:
31+
import StringIO # python 2
32+
h = StringIO.StringIO()
33+
except ImportError:
34+
import io # python 3
35+
h = io.StringIO()
36+
3037
sys.stdout = h
3138

3239
o = self.geosupport.help()

0 commit comments

Comments
 (0)