Skip to content

Commit

Permalink
Make uses of StringIO.StringIO Python 3 compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
thanatos committed Feb 27, 2016
1 parent 74a31c7 commit 8046cdc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions letsencrypt/tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import itertools
import os
import shutil
import StringIO
import traceback
import tempfile
import unittest

import mock
import six

from acme import jose

Expand Down Expand Up @@ -84,7 +84,7 @@ def test_no_flags(self):

def _help_output(self, args):
"Run a command, and return the ouput string for scrutiny"
output = StringIO.StringIO()
output = six.StringIO()
with mock.patch('letsencrypt.cli.sys.stdout', new=output):
self.assertRaises(SystemExit, self._call_stdout, args)
out = output.getvalue()
Expand Down
5 changes: 3 additions & 2 deletions letsencrypt/tests/colored_logging_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Tests for letsencrypt.colored_logging."""
import logging
import StringIO
import unittest

import six

from letsencrypt import le_util


Expand All @@ -12,7 +13,7 @@ class StreamHandlerTest(unittest.TestCase):
def setUp(self):
from letsencrypt import colored_logging

self.stream = StringIO.StringIO()
self.stream = six.StringIO()
self.stream.isatty = lambda: True
self.handler = colored_logging.StreamHandler(self.stream)

Expand Down
6 changes: 3 additions & 3 deletions letsencrypt/tests/le_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import os
import shutil
import stat
import StringIO
import tempfile
import unittest

import mock
import six

from letsencrypt import errors

Expand Down Expand Up @@ -307,14 +307,14 @@ def test_warning_with_arg(self):
self.assertTrue("--old-option is deprecated" in stderr)

def _get_argparse_warnings(self, args):
stderr = StringIO.StringIO()
stderr = six.StringIO()
with mock.patch("letsencrypt.le_util.sys.stderr", new=stderr):
self.parser.parse_args(args)
return stderr.getvalue()

def test_help(self):
self._call("--old-option", 2)
stdout = StringIO.StringIO()
stdout = six.StringIO()
with mock.patch("letsencrypt.le_util.sys.stdout", new=stdout):
try:
self.parser.parse_args(["-h"])
Expand Down
5 changes: 3 additions & 2 deletions letsencrypt/tests/reporter_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Tests for letsencrypt.reporter."""
import StringIO
import sys
import unittest

import six


class ReporterTest(unittest.TestCase):
"""Tests for letsencrypt.reporter.Reporter."""
Expand All @@ -12,7 +13,7 @@ def setUp(self):
self.reporter = reporter.Reporter()

self.old_stdout = sys.stdout
sys.stdout = StringIO.StringIO()
sys.stdout = six.StringIO()

def tearDown(self):
sys.stdout = self.old_stdout
Expand Down

0 comments on commit 8046cdc

Please sign in to comment.