From 097e3efbed216ababb5b2b5b36c7bc4fa1c9074e Mon Sep 17 00:00:00 2001 From: GregBestland Date: Thu, 14 Apr 2016 10:51:57 -0500 Subject: [PATCH] PYTHON-543 Forced cython validation --- build.yaml | 9 +++++---- tests/integration/__init__.py | 9 +++++++++ .../standard/test_cython_protocol_handlers.py | 18 ++++++++++++++++-- tests/unit/cython/utils.py | 5 +++-- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/build.yaml b/build.yaml index ee7dd4d9..e9f4b0c8 100644 --- a/build.yaml +++ b/build.yaml @@ -27,8 +27,9 @@ build: fi pip install -r test-requirements.txt pip install nose-ignore-docstring - + FORCE_CYTHON=False if [[ $CYTHON == 'CYTHON' ]]; then + FORCE_CYTHON=True pip install cython pip install numpy # Install the driver & compile C extensions @@ -39,12 +40,12 @@ build: fi echo "==========RUNNING CQLENGINE TESTS==========" - CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=cqle_results.xml tests/integration/cqlengine/ || true + CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=cqle_results.xml tests/integration/cqlengine/ || true echo "==========RUNNING INTEGRATION TESTS==========" - CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/ || true + CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/ || true echo "==========RUNNING LONG INTEGRATION TESTS==========" - CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true + CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true - xunit: - "*_results.xml" diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 4b3afaa0..178c1a5a 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -86,6 +86,15 @@ def _tuple_version(version_string): USE_CASS_EXTERNAL = bool(os.getenv('USE_CASS_EXTERNAL', False)) +# If set to to true this will force the Cython tests to run regardless of whether they are installed +cython_env = os.getenv('VERIFY_CYTHON', "False") + + +VERIFY_CYTHON = False + +if(cython_env == 'True'): + VERIFY_CYTHON = True + default_cassandra_version = '2.2.0' diff --git a/tests/integration/standard/test_cython_protocol_handlers.py b/tests/integration/standard/test_cython_protocol_handlers.py index dc24d0a3..53457c21 100644 --- a/tests/integration/standard/test_cython_protocol_handlers.py +++ b/tests/integration/standard/test_cython_protocol_handlers.py @@ -10,8 +10,8 @@ except ImportError: from cassandra.query import tuple_factory from cassandra.cluster import Cluster from cassandra.protocol import ProtocolHandler, LazyProtocolHandler, NumpyProtocolHandler - -from tests.integration import use_singledc, PROTOCOL_VERSION, notprotocolv1, drop_keyspace_shutdown_cluster +from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY +from tests.integration import use_singledc, PROTOCOL_VERSION, notprotocolv1, drop_keyspace_shutdown_cluster, VERIFY_CYTHON from tests.integration.datatype_utils import update_datatypes from tests.integration.standard.utils import ( create_table_with_all_types, get_all_primitive_params, get_primitive_datatypes) @@ -123,6 +123,20 @@ class CythonProtocolHandlerTest(unittest.TestCase): cluster.shutdown() + @numpytest + def test_cython_numpy_are_installed_valid(self): + """ + Test to validate that cython and numpy are installed correctly + @since 3.3.0 + @jira_ticket PYTHON-543 + @expected_result Cython and Numpy should be present + + @test_category configuration + """ + if VERIFY_CYTHON: + self.assertTrue(HAVE_CYTHON) + self.assertTrue(HAVE_NUMPY) + def _verify_numpy_page(self, page): colnames = self.colnames datatypes = get_primitive_datatypes() diff --git a/tests/unit/cython/utils.py b/tests/unit/cython/utils.py index 6dbeb15c..916de137 100644 --- a/tests/unit/cython/utils.py +++ b/tests/unit/cython/utils.py @@ -13,6 +13,7 @@ # limitations under the License. from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY +from tests.integration import VERIFY_CYTHON try: import unittest2 as unittest @@ -34,6 +35,6 @@ def cyimport(import_path): # @cythontest # def test_something(self): ... -cythontest = unittest.skipUnless(HAVE_CYTHON, 'Cython is not available') +cythontest = unittest.skipUnless((HAVE_CYTHON or VERIFY_CYTHON) or VERIFY_CYTHON, 'Cython is not available') notcython = unittest.skipIf(HAVE_CYTHON, 'Cython not supported') -numpytest = unittest.skipUnless(HAVE_CYTHON and HAVE_NUMPY, 'NumPy is not available') +numpytest = unittest.skipUnless((HAVE_CYTHON and HAVE_NUMPY) or VERIFY_CYTHON, 'NumPy is not available')