summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-04-19 22:16:48 -0700
committerDavid Lord <davidism@gmail.com>2020-04-19 23:58:30 -0700
commit56921211a3bdaefcc664994139979d25281167cf (patch)
tree3df16ddcbd4e8dd9e9eb17a370c0483e2bc95529 /tests
parent20fddf68e85ca98eff368aa171965754f9f446b5 (diff)
downloadclick-56921211a3bdaefcc664994139979d25281167cf.tar.gz
remove more compat code
Diffstat (limited to 'tests')
-rw-r--r--tests/test_imports.py9
-rw-r--r--tests/test_utils.py19
2 files changed, 4 insertions, 24 deletions
diff --git a/tests/test_imports.py b/tests/test_imports.py
index b99d453..be8730f 100644
--- a/tests/test_imports.py
+++ b/tests/test_imports.py
@@ -6,10 +6,7 @@ from click._compat import WIN
IMPORT_TEST = b"""\
-try:
- import __builtin__ as builtins
-except ImportError:
- import builtins
+import builtins
found_imports = set()
real_import = builtins.__import__
@@ -61,9 +58,7 @@ def test_light_imports():
[sys.executable, "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
rv = c.communicate(IMPORT_TEST)[0]
-
- if sys.version_info[0] != 2:
- rv = rv.decode("utf-8")
+ rv = rv.decode("utf-8")
imported = json.loads(rv)
for module in imported:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index d86f59b..2ca1a8a 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,6 +1,7 @@
import os
import stat
import sys
+from io import StringIO
import pytest
@@ -19,19 +20,7 @@ def test_echo(runner):
bytes = outstreams[0].getvalue().replace(b"\r\n", b"\n")
assert bytes == b"\xe2\x98\x83\nDD\n42ax"
- # If we are in Python 2, we expect that writing bytes into a string io
- # does not do anything crazy. In Python 3
- if sys.version_info[0] == 2:
- import StringIO
-
- sys.stdout = x = StringIO.StringIO()
- try:
- click.echo("\xf6")
- finally:
- sys.stdout = sys.__stdout__
- assert x.getvalue() == "\xf6\n"
-
- # And in any case, if wrapped, we expect bytes to survive.
+ # if wrapped, we expect bytes to survive.
@click.command()
def cli():
click.echo(b"\xf6")
@@ -224,10 +213,6 @@ def test_echo_color_flag(monkeypatch, capfd):
def test_echo_writing_to_standard_error(capfd, monkeypatch):
def emulate_input(text):
"""Emulate keyboard input."""
- if sys.version_info[0] == 2:
- from StringIO import StringIO
- else:
- from io import StringIO
monkeypatch.setattr(sys, "stdin", StringIO(text))
click.echo("Echo to standard output")