From 413234ce49022de704249ee9fbc9f61f7fa4320c Mon Sep 17 00:00:00 2001 From: Alexander Petrov Date: Thu, 20 Feb 2020 09:37:39 +0000 Subject: [PATCH] Replace `setup.py test` with pytest command (#380) Replace `setup.py test` with pytest command --- .travis.yml | 3 +++ setup.py | 7 ++++++- tests.sh | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe15c5575..2f28c102f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,10 +39,13 @@ matrix: - echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list - curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - - sudo apt-get update && sudo apt-get install bazel make + - sudo apt install python3-dev + - pip install -U pytest --user script: make all before_install: - sudo apt install python3-dev + - pip install -U pytest --user - go get github.com/axw/gocov/gocov - go get github.com/mattn/goveralls - go get github.com/fatih/color diff --git a/setup.py b/setup.py index 0e184d320..242c6ae78 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ from setuptools import setup from setuptools import Extension from setuptools.command.build_ext import build_ext as BuildExt +from setuptools.command.test import test as TestCommand from subprocess import Popen, PIPE DIR = os.path.abspath(os.path.dirname(__file__)) @@ -45,6 +46,10 @@ def run(self): BuildExt.run(self) +class NoopTestCommand(TestCommand): + def __init__(self, dist): + print("_gojsonnet does not support running tests with 'python setup.py test'. Please run 'pytest'.") + jsonnet_ext = Extension( '_gojsonnet', sources=MODULE_SOURCES, @@ -63,7 +68,7 @@ def run(self): version=get_version(), cmdclass={ 'build_ext': BuildJsonnetExt, + 'test': NoopTestCommand, }, ext_modules=[jsonnet_ext], - test_suite="python._jsonnet_test", ) diff --git a/tests.sh b/tests.sh index 0efbf15fe..891ffc3d3 100755 --- a/tests.sh +++ b/tests.sh @@ -14,8 +14,8 @@ then else c-bindings-tests/run.sh - $PYTHON_COMMAND setup.py build - $PYTHON_COMMAND setup.py test + $PYTHON_COMMAND setup.py build --build-platlib . + $PYTHON_COMMAND -m pytest python fi export IMPLEMENTATION=golang