src/tests/__init__.py: fix CommandLineTests on python3
This commit is contained in:
parent
78183c642b
commit
0639dbd47c
1 changed files with 19 additions and 11 deletions
|
@ -435,11 +435,19 @@ def tiff_header_for_ccitt(width, height, img_size, ccitt_group=4):
|
||||||
|
|
||||||
class CommandLineTests(unittest.TestCase):
|
class CommandLineTests(unittest.TestCase):
|
||||||
def test_main_help(self):
|
def test_main_help(self):
|
||||||
|
if PY3:
|
||||||
|
from contextlib import redirect_stdout
|
||||||
|
f = StringIO()
|
||||||
|
with redirect_stdout(f):
|
||||||
|
try:
|
||||||
|
img2pdf.main(['img2pdf', '--help'])
|
||||||
|
except SystemExit:
|
||||||
|
pass
|
||||||
|
res = f.getvalue()
|
||||||
|
self.assertIn('img2pdf', res)
|
||||||
|
else:
|
||||||
# silence output
|
# silence output
|
||||||
sys_stdout = sys.stdout
|
sys_stdout = sys.stdout
|
||||||
if PY3:
|
|
||||||
sys.stdout = TextIOWrapper(BytesIO())
|
|
||||||
else:
|
|
||||||
sys.stdout = BytesIO()
|
sys.stdout = BytesIO()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue