Skip to content

Commit

Permalink
Merge pull request #233 from hynek/pytest
Browse files Browse the repository at this point in the history
Use py.test test runner
  • Loading branch information
reaperhulk committed Apr 15, 2015
2 parents 56e8af6 + f982efd commit 0959cb6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__
.tox
doc/_build/
.coverage
.eggs
32 changes: 31 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,36 @@
Installation script for the OpenSSL module
"""

import sys

from setuptools import setup
from setuptools.command.test import test as TestCommand


# XXX Deduplicate this
__version__ = '0.15.1'


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='pyOpenSSL', version=__version__,
packages = ['OpenSSL'],
package_dir = {'OpenSSL': 'OpenSSL'},
Expand Down Expand Up @@ -75,4 +99,10 @@
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Networking',
],
test_suite="OpenSSL")
test_suite="OpenSSL",
tests_require=[
"pytest",
],
cmdclass={
"test": PyTest,
})
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ envlist = pypy,py26,py27,py32,py33,py34

[testenv]
deps =
setuptools>=7.0
setuptools>=7.0 # older setuptools pollute CWD with egg files of dependencies
coverage
setenv =
# Do not allowed the executing environment to pollute the test environment
# with extra packages.
PYTHONPATH=
# The standard library unittest module can run tests on Python 2.7 and newer
commands =
python -c "import OpenSSL.SSL; print(OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION))"
coverage run --branch --source=OpenSSL setup.py test
Expand Down

0 comments on commit 0959cb6

Please sign in to comment.