diff options
author | Hynek Schlawack <hs@ox.cx> | 2015-10-16 20:18:38 +0200 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2015-10-17 11:27:56 +0200 |
commit | f0e6685b0880bbc30099c998454925ee8d39b14e (patch) | |
tree | ef387dada69f8fe9830fa1c9d9d289760fbbe5c1 | |
parent | 510a04eb7cb97fda2062c0c8b51724db2edbd855 (diff) | |
download | pyopenssl-f0e6685b0880bbc30099c998454925ee8d39b14e.tar.gz |
Move package into src
Prevents accidental imports when running tests.
-rw-r--r-- | .coveragerc | 12 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | runtests.py | 4 | ||||
-rwxr-xr-x | setup.py | 127 | ||||
-rw-r--r-- | src/OpenSSL/SSL.py (renamed from OpenSSL/SSL.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/__init__.py (renamed from OpenSSL/__init__.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/_util.py (renamed from OpenSSL/_util.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/crypto.py (renamed from OpenSSL/crypto.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/rand.py (renamed from OpenSSL/rand.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/tsafe.py (renamed from OpenSSL/tsafe.py) | 0 | ||||
-rw-r--r-- | src/OpenSSL/version.py (renamed from OpenSSL/version.py) | 0 | ||||
-rw-r--r-- | tests/README (renamed from OpenSSL/test/README) | 0 | ||||
-rw-r--r-- | tests/__init__.py (renamed from OpenSSL/test/__init__.py) | 0 | ||||
-rw-r--r-- | tests/memdbg.py (renamed from memdbg.py) | 0 | ||||
-rw-r--r-- | tests/test_crypto.py (renamed from OpenSSL/test/test_crypto.py) | 5 | ||||
-rw-r--r-- | tests/test_rand.py (renamed from OpenSSL/test/test_rand.py) | 3 | ||||
-rw-r--r-- | tests/test_ssl.py (renamed from OpenSSL/test/test_ssl.py) | 12 | ||||
-rw-r--r-- | tests/test_tsafe.py (renamed from OpenSSL/test/test_tsafe.py) | 3 | ||||
-rw-r--r-- | tests/test_util.py (renamed from OpenSSL/test/test_util.py) | 3 | ||||
-rw-r--r-- | tests/util.py (renamed from OpenSSL/test/util.py) | 2 | ||||
-rw-r--r-- | tox.ini | 23 |
21 files changed, 92 insertions, 104 deletions
diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..5bc0e03 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,12 @@ +[run] +branch = True +source = OpenSSL + +[paths] +source = + src/OpenSSL + .tox/*/lib/python*/site-packages/OpenSSL + .tox/pypy/site-packages/OpenSSL + +[report] +show_missing = True @@ -6,7 +6,7 @@ dist __pycache__ .tox doc/_build/ -.coverage +.coverage* .eggs examples/simple/*.cert examples/simple/*.pkey diff --git a/runtests.py b/runtests.py index 13f5c4c..85a96c8 100644 --- a/runtests.py +++ b/runtests.py @@ -3,9 +3,9 @@ sys.modules['ssl'] = None sys.modules['_hashlib'] = None try: - import memdbg + from OpenSSL.test import memdbg # noqa except Exception as e: - pass + pass from twisted.scripts.trial import run run() @@ -11,14 +11,12 @@ Installation script for the OpenSSL module. import codecs import os import re -import sys -from setuptools import setup -from setuptools.command.test import test as TestCommand +from setuptools import setup, find_packages HERE = os.path.abspath(os.path.dirname(__file__)) -META_PATH = os.path.join("OpenSSL", "version.py") +META_PATH = os.path.join("src", "OpenSSL", "version.py") def read_file(*parts): @@ -46,82 +44,45 @@ def find_meta(meta): raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) -class PyTest(TestCommand): - user_options = [("pytest-args=", "a", "Arguments to pass to py.test")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = None - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - # import here, cause outside the eggs aren't loaded - import pytest - errno = pytest.main(self.pytest_args or [] + - ["OpenSSL"]) - sys.exit(errno) - - -setup( - name=find_meta("title"), - version=find_meta("version"), - description=find_meta("summary"), - long_description=read_file("README.rst"), - author=find_meta("author"), - author_email=find_meta("email"), - maintainer="Hynek Schlawack", - maintainer_email="hs@ox.cx", - url=find_meta("uri"), - license=find_meta("license"), - classifiers=[ - 'Development Status :: 6 - Mature', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Security :: Cryptography', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: System :: Networking', - ], - - packages=['OpenSSL'], - package_dir={'OpenSSL': 'OpenSSL'}, - py_modules=['OpenSSL.__init__', - 'OpenSSL.tsafe', - 'OpenSSL.rand', - 'OpenSSL.crypto', - 'OpenSSL.SSL', - 'OpenSSL.version', - 'OpenSSL.test.__init__', - 'OpenSSL.test.util', - 'OpenSSL.test.test_crypto', - 'OpenSSL.test.test_rand', - 'OpenSSL.test.test_ssl', - 'OpenSSL.test.test_tsafe', - 'OpenSSL.test.test_util',], - install_requires=[ - "cryptography>=0.7", - "six>=1.5.2" - ], - test_suite="OpenSSL", - tests_require=[ - "pytest", - ], - cmdclass={ - "test": PyTest, - } -) +if __name__ == "__main__": + setup( + name=find_meta("title"), + version=find_meta("version"), + description=find_meta("summary"), + long_description=read_file("README.rst"), + author=find_meta("author"), + author_email=find_meta("email"), + maintainer="Hynek Schlawack", + maintainer_email="hs@ox.cx", + url=find_meta("uri"), + license=find_meta("license"), + classifiers=[ + 'Development Status :: 6 - Mature', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Topic :: Security :: Cryptography', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: System :: Networking', + ], + + packages=find_packages(where="src"), + package_dir={"": "src"}, + install_requires=[ + "cryptography>=0.7", + "six>=1.5.2" + ], + ) diff --git a/OpenSSL/SSL.py b/src/OpenSSL/SSL.py index 190e4ac..190e4ac 100644 --- a/OpenSSL/SSL.py +++ b/src/OpenSSL/SSL.py diff --git a/OpenSSL/__init__.py b/src/OpenSSL/__init__.py index 3c80e54..3c80e54 100644 --- a/OpenSSL/__init__.py +++ b/src/OpenSSL/__init__.py diff --git a/OpenSSL/_util.py b/src/OpenSSL/_util.py index 074ef3d..074ef3d 100644 --- a/OpenSSL/_util.py +++ b/src/OpenSSL/_util.py diff --git a/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 132d98d..132d98d 100644 --- a/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py diff --git a/OpenSSL/rand.py b/src/OpenSSL/rand.py index 65cd597..65cd597 100644 --- a/OpenSSL/rand.py +++ b/src/OpenSSL/rand.py diff --git a/OpenSSL/tsafe.py b/src/OpenSSL/tsafe.py index ba17d73..ba17d73 100644 --- a/OpenSSL/tsafe.py +++ b/src/OpenSSL/tsafe.py diff --git a/OpenSSL/version.py b/src/OpenSSL/version.py index f284b04..f284b04 100644 --- a/OpenSSL/version.py +++ b/src/OpenSSL/version.py diff --git a/OpenSSL/test/README b/tests/README index 8b3b3ff..8b3b3ff 100644 --- a/OpenSSL/test/README +++ b/tests/README diff --git a/OpenSSL/test/__init__.py b/tests/__init__.py index 9b08060..9b08060 100644 --- a/OpenSSL/test/__init__.py +++ b/tests/__init__.py diff --git a/memdbg.py b/tests/memdbg.py index 324d0fd..324d0fd 100644 --- a/memdbg.py +++ b/tests/memdbg.py diff --git a/OpenSSL/test/test_crypto.py b/tests/test_crypto.py index 0c906b6..196e490 100644 --- a/OpenSSL/test/test_crypto.py +++ b/tests/test_crypto.py @@ -35,10 +35,11 @@ from OpenSSL.crypto import CRL, Revoked, load_crl from OpenSSL.crypto import NetscapeSPKI, NetscapeSPKIType from OpenSSL.crypto import ( sign, verify, get_elliptic_curve, get_elliptic_curves) -from OpenSSL.test.util import ( +from OpenSSL._util import native, lib + +from .util import ( EqualityTestsMixin, TestCase, WARNING_TYPE_EXPECTED ) -from OpenSSL._util import native, lib def normalize_certificate_pem(pem): diff --git a/OpenSSL/test/test_rand.py b/tests/test_rand.py index d5d75cb..8064011 100644 --- a/OpenSSL/test/test_rand.py +++ b/tests/test_rand.py @@ -10,9 +10,10 @@ import os import stat import sys -from OpenSSL.test.util import NON_ASCII, TestCase, b from OpenSSL import rand +from .util import NON_ASCII, TestCase, b + class RandTests(TestCase): def test_bytes_wrong_args(self): diff --git a/OpenSSL/test/test_ssl.py b/tests/test_ssl.py index 3db1f8f..4aac429 100644 --- a/OpenSSL/test/test_ssl.py +++ b/tests/test_ssl.py @@ -47,12 +47,6 @@ from OpenSSL.SSL import ( from OpenSSL._util import lib as _lib -from OpenSSL.test.util import WARNING_TYPE_EXPECTED, NON_ASCII, TestCase, b -from OpenSSL.test.test_crypto import ( - cleartextCertificatePEM, cleartextPrivateKeyPEM, - client_cert_pem, client_key_pem, server_cert_pem, server_key_pem, - root_cert_pem) - try: from OpenSSL.SSL import OP_NO_QUERY_MTU except ImportError: @@ -89,6 +83,12 @@ from OpenSSL.SSL import ( SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP, SSL_CB_CONNECT_EXIT, SSL_CB_HANDSHAKE_START, SSL_CB_HANDSHAKE_DONE) +from .util import WARNING_TYPE_EXPECTED, NON_ASCII, TestCase, b +from .test_crypto import ( + cleartextCertificatePEM, cleartextPrivateKeyPEM, + client_cert_pem, client_key_pem, server_cert_pem, server_key_pem, + root_cert_pem) + # openssl dhparam 128 -out dh-128.pem (note that 128 is a small number of bits # to use) diff --git a/OpenSSL/test/test_tsafe.py b/tests/test_tsafe.py index 0456957..97045ce 100644 --- a/OpenSSL/test/test_tsafe.py +++ b/tests/test_tsafe.py @@ -7,7 +7,8 @@ Unit tests for :py:obj:`OpenSSL.tsafe`. from OpenSSL.SSL import TLSv1_METHOD, Context from OpenSSL.tsafe import Connection -from OpenSSL.test.util import TestCase + +from .util import TestCase class ConnectionTest(TestCase): diff --git a/OpenSSL/test/test_util.py b/tests/test_util.py index 24ccc1d..2aaded2 100644 --- a/OpenSSL/test/test_util.py +++ b/tests/test_util.py @@ -1,5 +1,6 @@ from OpenSSL._util import exception_from_error_queue, lib -from OpenSSL.test.util import TestCase + +from .util import TestCase class ErrorTests(TestCase): diff --git a/OpenSSL/test/util.py b/tests/util.py index b0a5d62..5b53dc2 100644 --- a/OpenSSL/test/util.py +++ b/tests/util.py @@ -22,7 +22,7 @@ from OpenSSL._util import exception_from_error_queue from OpenSSL.crypto import Error -import memdbg +from . import memdbg from OpenSSL._util import ffi, lib, byte_string as b @@ -1,30 +1,29 @@ [tox] -envlist = {pypy,py26,py27,py33,py34,py35}{,-cryptographyMaster},pypi-readme,check-manifest,flake8,pyroma,docs +envlist = coverage-clean,{pypy,py26,py27,py33,py34,py35}{,-cryptographyMaster},pypi-readme,check-manifest,flake8,pyroma,docs,coverage-report [testenv] whitelist_externals = openssl passenv = ARCHFLAGS CFLAGS LC_ALL LDFLAGS PATH LD_LIBRARY_PATH deps = - setuptools>=7.0 # older setuptools pollute CWD with egg files of dependencies coverage + pytest cryptographyMaster: git+https://github.com/pyca/cryptography.git setenv = - # Do not allowed the executing environment to pollute the test environment + # Do not allow the executing environment to pollute the test environment # with extra packages. PYTHONPATH= commands = openssl version python -c "import OpenSSL.SSL; print(OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION))" python -c "import cryptography; print(cryptography.__version__)" - coverage run --branch --source=OpenSSL setup.py test - coverage report -m + coverage run --parallel -m pytest tests [testenv:flake8] deps = flake8 commands = - flake8 OpenSSL + flake8 src tests setup.py [testenv:pyroma] deps = @@ -49,3 +48,15 @@ deps = -rdocs-requirements.txt basepython = python2.7 commands = sphinx-build -W -b html doc doc/_build/html + +[testenv:coverage-clean] +deps = coverage +skip_install = true +commands = coverage erase + +[testenv:coverage-report] +deps = coverage +skip_install = true +commands = + coverage combine + coverage report |