From 8ea8d4785ea4e0e8df75250aeebc3961876c4481 Mon Sep 17 00:00:00 2001 From: "Sybren A. St?vel" Date: Thu, 14 Jan 2016 12:23:32 +0100 Subject: Removed dependency on unittest2, also merged requirements.txt for py 2.x and 3.x --- requirements-dev-py2x.txt | 5 ---- requirements-dev-py3x.txt | 6 ----- requirements.txt | 4 ++++ run_tests.py | 57 -------------------------------------------- tests/test_bigfile.py | 4 ++-- tests/test_common.py | 8 +++---- tests/test_compat.py | 4 ++-- tests/test_integers.py | 4 ++-- tests/test_load_save_keys.py | 6 ++--- tests/test_pem.py | 4 ++-- tests/test_pkcs1.py | 6 ++--- tests/test_strings.py | 4 ++-- tests/test_transform.py | 4 ++-- tox.ini | 2 -- 14 files changed, 26 insertions(+), 92 deletions(-) delete mode 100644 requirements-dev-py2x.txt delete mode 100644 requirements-dev-py3x.txt create mode 100644 requirements.txt delete mode 100644 run_tests.py diff --git a/requirements-dev-py2x.txt b/requirements-dev-py2x.txt deleted file mode 100644 index c62d8c0..0000000 --- a/requirements-dev-py2x.txt +++ /dev/null @@ -1,5 +0,0 @@ -nose -sphinx -pyasn1>=0.1.3 -tox -unittest2 diff --git a/requirements-dev-py3x.txt b/requirements-dev-py3x.txt deleted file mode 100644 index 3e4df7b..0000000 --- a/requirements-dev-py3x.txt +++ /dev/null @@ -1,6 +0,0 @@ -nose -sphinx -pyasn1>=0.1.3 -tox -unittest2py3k -wheel diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f1c6af1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +sphinx +pyasn1>=0.1.3 +tox +wheel diff --git a/run_tests.py b/run_tests.py deleted file mode 100644 index 10451d1..0000000 --- a/run_tests.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright 2011 Sybren A. Stüvel -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys -import unittest2 as unittest - -current_path = os.path.abspath(os.path.dirname(__file__)) -tests_path = os.path.join(current_path, 'tests') -sys.path[0:0] = [ - current_path, - tests_path, -] - -all_tests = [f[:-3] for f in os.listdir(tests_path) - if f.startswith('test_') and f.endswith(".py")] - -def get_suite(tests): - tests = sorted(tests) - suite = unittest.TestSuite() - loader = unittest.TestLoader() - for test in tests: - suite.addTest(loader.loadTestsFromName(test)) - return suite - -if __name__ == '__main__': - """ - To run all tests: - $ python run_tests.py - To run a single test: - $ python run_tests.py app - To run a couple of tests: - $ python run_tests.py app config sessions - To run code coverage: - $ coverage run run_tests.py - $ coverage report -m - """ - tests = sys.argv[1:] - if not tests: - tests = all_tests - tests = ['%s' % t for t in tests] - suite = get_suite(tests) - unittest.TextTestRunner(verbosity=1).run(suite) diff --git a/tests/test_bigfile.py b/tests/test_bigfile.py index 6c3de00..b45b52f 100644 --- a/tests/test_bigfile.py +++ b/tests/test_bigfile.py @@ -21,12 +21,12 @@ try: from StringIO import StringIO as BytesIO except ImportError: from io import BytesIO -import unittest2 +import unittest import rsa from rsa import bigfile, varblock, pkcs1 -class BigfileTest(unittest2.TestCase): +class BigfileTest(unittest.TestCase): def test_encrypt_decrypt_bigfile(self): diff --git a/tests/test_common.py b/tests/test_common.py index eba5d27..a563d21 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -15,13 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest2 +import unittest import struct from rsa._compat import byte, b from rsa.common import byte_size, bit_size, _bit_size -class Test_byte(unittest2.TestCase): +class Test_byte(unittest.TestCase): def test_values(self): self.assertEqual(byte(0), b('\x00')) self.assertEqual(byte(255), b('\xff')) @@ -30,7 +30,7 @@ class Test_byte(unittest2.TestCase): self.assertRaises(struct.error, byte, 256) self.assertRaises(struct.error, byte, -1) -class Test_byte_size(unittest2.TestCase): +class Test_byte_size(unittest.TestCase): def test_values(self): self.assertEqual(byte_size(1 << 1023), 128) self.assertEqual(byte_size((1 << 1024) - 1), 128) @@ -55,7 +55,7 @@ class Test_byte_size(unittest2.TestCase): self.assertRaises(TypeError, byte_size, "") self.assertRaises(TypeError, byte_size, None) -class Test_bit_size(unittest2.TestCase): +class Test_bit_size(unittest.TestCase): def test_zero(self): self.assertEqual(bit_size(0), 0) diff --git a/tests/test_compat.py b/tests/test_compat.py index 1788ff0..2ab7fd2 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest2 +import unittest import struct from rsa._compat import is_bytes, byte -class Test_byte(unittest2.TestCase): +class Test_byte(unittest.TestCase): def test_byte(self): for i in range(256): byt = byte(i) diff --git a/tests/test_integers.py b/tests/test_integers.py index f504e45..118204a 100644 --- a/tests/test_integers.py +++ b/tests/test_integers.py @@ -16,11 +16,11 @@ '''Tests integer operations.''' -import unittest2 +import unittest import rsa.core -class IntegerTest(unittest2.TestCase): +class IntegerTest(unittest.TestCase): def setUp(self): (self.pub, self.priv) = rsa.newkeys(64) diff --git a/tests/test_load_save_keys.py b/tests/test_load_save_keys.py index 1a4ee23..b2b4071 100644 --- a/tests/test_load_save_keys.py +++ b/tests/test_load_save_keys.py @@ -17,7 +17,7 @@ '''Unittest for saving and loading keys.''' import base64 -import unittest2 +import unittest from rsa._compat import b import rsa.key @@ -69,7 +69,7 @@ CLEAN_PUBLIC_PEM = b('''\ ''' % B64PUB_DER.decode("utf-8")) -class DerTest(unittest2.TestCase): +class DerTest(unittest.TestCase): '''Test saving and loading DER keys.''' def test_load_private_key(self): @@ -104,7 +104,7 @@ class DerTest(unittest2.TestCase): self.assertEqual(PUBLIC_DER, der) -class PemTest(unittest2.TestCase): +class PemTest(unittest.TestCase): '''Test saving and loading PEM keys.''' diff --git a/tests/test_pem.py b/tests/test_pem.py index d1dcf3a..de1b8a6 100644 --- a/tests/test_pem.py +++ b/tests/test_pem.py @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest2 +import unittest from rsa._compat import b from rsa.pem import _markers -class Test__markers(unittest2.TestCase): +class Test__markers(unittest.TestCase): def test_values(self): self.assertEqual(_markers('RSA PRIVATE KEY'), (b('-----BEGIN RSA PRIVATE KEY-----'), diff --git a/tests/test_pkcs1.py b/tests/test_pkcs1.py index 6150215..7b92197 100644 --- a/tests/test_pkcs1.py +++ b/tests/test_pkcs1.py @@ -17,13 +17,13 @@ '''Tests string operations.''' import struct -import unittest2 +import unittest import rsa from rsa import pkcs1 from rsa._compat import byte, is_integer, b, is_bytes -class BinaryTest(unittest2.TestCase): +class BinaryTest(unittest.TestCase): def setUp(self): (self.pub, self.priv) = rsa.newkeys(256) @@ -66,7 +66,7 @@ class BinaryTest(unittest2.TestCase): self.assertNotEqual(encrypted1, encrypted2) -class SignatureTest(unittest2.TestCase): +class SignatureTest(unittest.TestCase): def setUp(self): (self.pub, self.priv) = rsa.newkeys(512) diff --git a/tests/test_strings.py b/tests/test_strings.py index fe60055..c4ee4c4 100644 --- a/tests/test_strings.py +++ b/tests/test_strings.py @@ -18,13 +18,13 @@ from __future__ import absolute_import -import unittest2 +import unittest import rsa from constants import unicode_string -class StringTest(unittest2.TestCase): +class StringTest(unittest.TestCase): def setUp(self): (self.pub, self.priv) = rsa.newkeys(384) diff --git a/tests/test_transform.py b/tests/test_transform.py index ed3e38b..f919b1b 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest2 +import unittest from rsa._compat import b from rsa.transform import int2bytes, bytes2int, _int2bytes -class Test_int2bytes(unittest2.TestCase): +class Test_int2bytes(unittest.TestCase): def test_accuracy(self): self.assertEqual(int2bytes(123456789), b('\x07[\xcd\x15')) self.assertEqual(_int2bytes(123456789), b('\x07[\xcd\x15')) diff --git a/tox.ini b/tox.ini index da0e3c6..5932192 100644 --- a/tox.ini +++ b/tox.ini @@ -11,8 +11,6 @@ setenv = commands=py.test [] deps=pyasn1 >=0.1.3 coverage >=3.5 - unittest2 PyTest pytest-xdist pytest-cov - -- cgit v1.2.1