You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2017/05/02 05:12:17 UTC
[07/12] libcloud git commit: move setuptools to pytest
move setuptools to pytest
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b4ce9367
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b4ce9367
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b4ce9367
Branch: refs/heads/trunk
Commit: b4ce9367f58d5b702b4efad5b3188791071a86e6
Parents: 047b75e
Author: Anthony Shaw <an...@apache.org>
Authored: Mon Apr 24 14:06:45 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Mon Apr 24 14:06:45 2017 +1000
----------------------------------------------------------------------
setup.cfg | 7 +++
setup.py | 142 +++------------------------------------------------------
2 files changed, 13 insertions(+), 136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/b4ce9367/setup.cfg
----------------------------------------------------------------------
diff --git a/setup.cfg b/setup.cfg
index bcb0348..eeb81dc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,3 +3,10 @@ universal = 1
[nosetests]
exclude=TestCaseMixin
+
+[aliases]
+test=pytest
+
+[tool:pytest]
+python_classes=*Test
+testpaths=libcloud/test
http://git-wip-us.apache.org/repos/asf/libcloud/blob/b4ce9367/setup.py
----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index 1e05352..218f4f8 100644
--- a/setup.py
+++ b/setup.py
@@ -14,13 +14,10 @@
# limitations under the License.
import os
import sys
-import doctest
from setuptools import setup
from distutils.core import Command
-from unittest import TextTestRunner, TestLoader
-from glob import glob
-from os.path import splitext, basename, join as pjoin
+from os.path import join as pjoin
try:
import epydoc # NOQA
@@ -61,7 +58,9 @@ SUPPORTED_VERSIONS = ['2.6', '2.7', 'PyPy', '3.x']
TEST_REQUIREMENTS = [
'mock',
- 'requests'
+ 'requests',
+ 'pytest',
+ 'pytest-runner'
]
if PY2_pre_279 or PY3_pre_32:
@@ -99,113 +98,6 @@ def forbid_publish():
sys.exit(1)
-class TestCommand(Command):
- description = "run test suite"
- user_options = []
- unittest_TestLoader = TestLoader
- unittest_TextTestRunner = TextTestRunner
-
- def initialize_options(self):
- THIS_DIR = os.path.abspath(os.path.split(__file__)[0])
- sys.path.insert(0, THIS_DIR)
- for test_path in TEST_PATHS:
- sys.path.insert(0, pjoin(THIS_DIR, test_path))
- self._dir = os.getcwd()
-
- def finalize_options(self):
- pass
-
- def run(self):
- for module_name in TEST_REQUIREMENTS:
- try:
- __import__(module_name)
- except ImportError:
- print('Missing "%s" library. %s is library is needed '
- 'to run the tests. You can install it using pip: '
- 'pip install %s' % (module_name, module_name,
- module_name))
- sys.exit(1)
-
- if unittest2_required:
- try:
- from unittest2 import TextTestRunner, TestLoader
- self.unittest_TestLoader = TestLoader
- self.unittest_TextTestRunner = TextTestRunner
- except ImportError:
- print('Python version: %s' % (sys.version))
- print('Missing "unittest2" library. unittest2 is library is '
- 'needed to run the tests. You can install it using pip: '
- 'pip install unittest2')
- sys.exit(1)
-
- status = self._run_tests()
- sys.exit(status)
-
- def _run_tests(self):
- secrets_current = pjoin(self._dir, 'libcloud/test', 'secrets.py')
- secrets_dist = pjoin(self._dir, 'libcloud/test', 'secrets.py-dist')
-
- if not os.path.isfile(secrets_current):
- print("Missing " + secrets_current)
- print("Maybe you forgot to copy it from -dist:")
- print("cp libcloud/test/secrets.py-dist libcloud/test/secrets.py")
- sys.exit(1)
-
- mtime_current = os.path.getmtime(secrets_current)
- mtime_dist = os.path.getmtime(secrets_dist)
-
- if mtime_dist > mtime_current:
- print("It looks like test/secrets.py file is out of date.")
- print("Please copy the new secrets.py-dist file over otherwise" +
- " tests might fail")
-
- if PY2_pre_26:
- missing = []
- # test for dependencies
- try:
- import simplejson
- simplejson # silence pyflakes
- except ImportError:
- missing.append("simplejson")
-
- try:
- import ssl
- ssl # silence pyflakes
- except ImportError:
- missing.append("ssl")
-
- if missing:
- print("Missing dependencies: " + ", ".join(missing))
- sys.exit(1)
-
- testfiles = []
- for test_path in TEST_PATHS:
- for t in glob(pjoin(self._dir, test_path, 'test_*.py')):
- testfiles.append('.'.join(
- [test_path.replace('/', '.'), splitext(basename(t))[0]]))
-
- # Test loader simply throws "'module' object has no attribute" error
- # if there is an issue with the test module so we manually try to
- # import each module so we get a better and more friendly error message
- for test_file in testfiles:
- try:
- __import__(test_file)
- except Exception:
- e = sys.exc_info()[1]
- print('Failed to import test module "%s": %s' % (test_file,
- str(e)))
- raise e
-
- tests = self.unittest_TestLoader().loadTestsFromNames(testfiles)
-
- for test_module in DOC_TEST_MODULES:
- tests.addTests(doctest.DocTestSuite(test_module))
-
- t = self.unittest_TextTestRunner(verbosity=2)
- res = t.run(tests)
- return not res.wasSuccessful()
-
-
class ApiDocsCommand(Command):
description = "generate API documentation"
user_options = []
@@ -231,28 +123,6 @@ class ApiDocsCommand(Command):
% (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR))
-class CoverageCommand(Command):
- description = "run test suite and generate coverage report"
- user_options = []
-
- def initialize_options(self):
- pass
-
- def finalize_options(self):
- pass
-
- def run(self):
- import coverage
- cov = coverage.coverage(config_file='.coveragerc')
- cov.start()
-
- tc = TestCommand(self.distribution)
- tc._run_tests()
-
- cov.stop()
- cov.save()
- cov.html_report()
-
forbid_publish()
install_requires = ['requests']
@@ -278,10 +148,10 @@ setup(
package_data={'libcloud': get_data_files('libcloud', parent='libcloud')},
license='Apache License (2.0)',
url='http://libcloud.apache.org/',
+ setup_requires=['pytest-runner'],
+ tests_require=TEST_REQUIREMENTS,
cmdclass={
- 'test': TestCommand,
'apidocs': ApiDocsCommand,
- 'coverage': CoverageCommand
},
zip_safe=False,
classifiers=[