diff --git a/cirrus.conf b/cirrus.conf index 546bc01..cba5c5c 100644 --- a/cirrus.conf +++ b/cirrus.conf @@ -1,6 +1,6 @@ [package] name = cirrus-cli -version = 3.1.0 +version = 3.1.1 description = cirrus development and build git extensions organization = cloudant version_file = src/cirrus/__init__.py diff --git a/installer.sh b/installer.sh index 4b15020..8f0a544 100644 --- a/installer.sh +++ b/installer.sh @@ -37,6 +37,10 @@ cd ${LOCATION} python -m venv venv . venv/bin/activate +# Upgrade to the latest pip, otherwise the default 9.x version has trouble +# with escaped @ characters in pip.conf +pip install -i https://pypi.python.org/simple -U pip setuptools + # This depends on a properly configured pip.conf file. # See https://github.com/cloudant/service_engineering/wiki/Using-JFrog-Artifactory pip install cirrus-cli${CIRRUS_INSTALL_VERSION} 1>> ${LOCATION}/install.log diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..8203fca --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +python_files = + *_test.py + *_tests.py diff --git a/requirements.txt b/requirements.txt index 0650d82..9e620ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,9 +2,9 @@ argparse==1.2.1 arrow==0.4.2 Fabric==2.4.0 GitPython==2.1.9 -nose==1.3.0 pep8==1.5.7 pylint==1.3.0 +pytest requests==2.3.0 PyChef==0.2.3 keyring==8.5.1 @@ -13,5 +13,4 @@ pluggage dockerstache>=0.0.9 requests-toolbelt==0.6.2 tox -wheel - +wheel \ No newline at end of file diff --git a/src/cirrus/__init__.py b/src/cirrus/__init__.py index 5195a4b..ab7d2a4 100644 --- a/src/cirrus/__init__.py +++ b/src/cirrus/__init__.py @@ -18,5 +18,5 @@ See the License for the specific language governing permissions and limitations under the License. """ -__version__="3.1.0" +__version__="3.1.1" diff --git a/src/cirrus/test.py b/src/cirrus/test.py index 74dc785..06789bc 100644 --- a/src/cirrus/test.py +++ b/src/cirrus/test.py @@ -21,7 +21,6 @@ def build_parser(argslist): parser = ArgumentParser( description='git cirrus test command' ) - parser.add_argument( '--suite', help=( @@ -32,8 +31,8 @@ def build_parser(argslist): ) parser.add_argument( '--mode', - choices=['nosetests', 'tox'], - default=None, + choices=['nosetests', 'pytest', 'tox'], + default='pytest', help='Choose test runner framework' ) parser.add_argument( @@ -62,6 +61,21 @@ def nose_run(config, opts): ) +def pytest_run(config, opts): + """ + Locally activate virtualenv and run tests with pytest + """ + testpath = config.test_where(opts.suite) + command = ( + '. ./{}/bin/activate && pytest {} {}'.format( + config.venv_name(), + testpath, + opts.options + ) + ) + run(command, pty=True) # pty preserves pytest colors + + def tox_run(config, opts): """ tox test @@ -85,20 +99,20 @@ def main(): """ opts = build_parser(sys.argv[1:]) config = load_configuration() - mode = config.test_mode(opts.suite) - if opts.mode: - mode = opts.mode - - # backwards compat: default to nosetests - if mode is None: - mode = 'nosetests' - - if mode == 'nosetests': - nose_run(config, opts) - sys.exit(0) - if mode == 'tox': - tox_run(config, opts) - sys.exit(0) + testrunners = { + 'nosetest': nose_run, + 'pytest': pytest_run, + 'tox': tox_run + } + + try: + testrunner = testrunners[opts.mode] + except KeyError as ex: + # argpase will catch this first, but just in case... + sys.exit("Invalid selection for --mode: {}".format(ex)) + + testrunner(config, opts) + sys.exit(0) if __name__ == '__main__':