summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Manganiello <adamantike@users.noreply.github.com>2017-01-15 12:30:37 -0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-01-15 16:30:37 +0100
commit81f0e95dd17bbe99df2ac4958bd9511dd05c788f (patch)
tree675386f2627a781c6f2886cf5060473c0109ab1c /tests
parent0c906333048f1760d27e579ce5fd7a140ee2b62c (diff)
downloadrsa-git-81f0e95dd17bbe99df2ac4958bd9511dd05c788f.tar.gz
Create PY2 constant to simplify compatibility decisions (#82)
It's about time to get this merged, thanks again!
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cli.py26
-rw-r--r--tests/test_compat.py1
2 files changed, 12 insertions, 15 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 4ae8da3..7ce57eb 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -15,25 +15,23 @@ from io import StringIO, BytesIO
import rsa
import rsa.cli
import rsa.util
+from rsa._compat import PY2
-if sys.version_info[0] < 3:
- def make_buffer():
+
+def make_buffer():
+ if PY2:
return BytesIO()
+ buf = StringIO()
+ buf.buffer = BytesIO()
+ return buf
- def get_bytes_out(out):
- # Python 2.x writes 'str' to stdout:
+def get_bytes_out(out):
+ if PY2:
+ # Python 2.x writes 'str' to stdout
return out.getvalue()
-else:
- def make_buffer():
- buf = StringIO()
- buf.buffer = BytesIO()
- return buf
-
-
- def get_bytes_out(out):
- # Python 3.x writes 'bytes' to stdout.buffer:
- return out.buffer.getvalue()
+ # Python 3.x writes 'bytes' to stdout.buffer
+ return out.buffer.getvalue()
@contextmanager
diff --git a/tests/test_compat.py b/tests/test_compat.py
index 0013155..a47f890 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -16,7 +16,6 @@
import unittest
import struct
-import sys
from rsa._compat import byte, is_bytes, range