diff --git a/.gitignore b/.gitignore index 147e7e1e..33e26ed4 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ dist **/wheelhouse/* # coverage .coverage +.nox # OS generated files # ###################### diff --git a/.travis.yml b/.travis.yml index 42378680..bce116d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,48 +3,50 @@ sudo: false language: python env: - - PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true' - - PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false' - - PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false' - - PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true' + - PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true' PYENV_VERSION=2.7.14 + - PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false' PYENV_VERSION=3.5.4 + - PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false' PYENV_VERSION=3.6.1 + - PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true' PYENV_VERSION=3.6.1 before_install: - echo "before_install" - source ci/travis_process_gbq_encryption.sh install: - - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda config --add channels pandas - - conda config --add channels conda-forge - - conda update -q conda - - conda info -a - - conda create -q -n test-environment python=$PYTHON - - source activate test-environment - - if [[ "$PANDAS" == "MASTER" ]]; then - conda install -q numpy pytz python-dateutil; - PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"; - pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS pandas; - pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core'; - pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core'; - pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery'; + # work around https://github.com/travis-ci/travis-ci/issues/8363 + # https://github.com/pre-commit/pre-commit/commit/e3ab8902692e896da9ded42bd4d76ea4e1de359d + - pyenv install -s $PYENV_VERSION + - pyenv global system $PYENV_VERSION + - REQ="ci/requirements-${PYTHON}-${PANDAS}" ; + if [ -f "$REQ.pip" ]; then + pip install --upgrade nox-automation ; else + wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + bash miniconda.sh -b -p $HOME/miniconda ; + export PATH="$HOME/miniconda/bin:$PATH" ; + hash -r ; + conda config --set always_yes yes --set changeps1 no ; + conda config --add channels pandas ; + conda config --add channels conda-forge ; + conda update -q conda ; + conda info -a ; + conda create -q -n test-environment python=$PYTHON ; + source activate test-environment ; conda install -q pandas=$PANDAS; - fi - - pip install coverage pytest pytest-cov flake8 codecov - - REQ="ci/requirements-${PYTHON}-${PANDAS}" - - if [ -f "$REQ.pip" ]; then - pip install -r "$REQ.pip"; - else + pip install coverage pytest pytest-cov flake8 codecov ; conda install -q --file "$REQ.conda"; + conda list ; + python setup.py install ; fi - - conda list - - python setup.py install script: - - pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq - - if [[ $COVERAGE == 'true' ]]; then codecov ; fi - - if [[ $LINT == 'true' ]]; then flake8 pandas_gbq -v ; fi + - if [[ $PYTHON == '2.7' ]]; then nox -s test27 ; fi + - if [[ $PYTHON == '3.5' ]]; then nox -s test35 ; fi + - if [[ $PYTHON == '3.6' ]] && [[ "$PANDAS" == "MASTER" ]]; then nox -s test36master ; fi + - REQ="ci/requirements-${PYTHON}-${PANDAS}" ; + if [ -f "$REQ.conda" ]; then + pip install coverage pytest pytest-cov codecov ; + pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq ; + fi + - if [[ $COVERAGE == 'true' ]]; then nox -s cover ; fi + - if [[ $LINT == 'true' ]]; then nox -s lint ; fi diff --git a/ci/requirements-3.5-0.18.1.pip b/ci/requirements-3.5-0.18.1.pip index 68ac370d..dd33895c 100644 --- a/ci/requirements-3.5-0.18.1.pip +++ b/ci/requirements-3.5-0.18.1.pip @@ -1,4 +1,3 @@ google-auth==1.4.1 google-auth-oauthlib==0.0.1 -mock google-cloud-bigquery==0.29.0 diff --git a/ci/requirements-3.6-0.20.1.conda b/ci/requirements-3.6-0.20.1.conda index b52f2aeb..e51ca487 100644 --- a/ci/requirements-3.6-0.20.1.conda +++ b/ci/requirements-3.6-0.20.1.conda @@ -1,4 +1,3 @@ google-auth google-auth-oauthlib -mock google-cloud-bigquery diff --git a/ci/requirements-3.6-MASTER.pip b/ci/requirements-3.6-MASTER.pip index 78f6834f..bd379b8b 100644 --- a/ci/requirements-3.6-MASTER.pip +++ b/ci/requirements-3.6-MASTER.pip @@ -1,3 +1,5 @@ google-auth google-auth-oauthlib -mock +git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core +git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core +git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index ffa62f1a..f7711442 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,11 @@ Changelog ========= +0.5.0 / TBD +----------- + +- Tests now use `nox` to run in multiple Python environments. (:issue:`52`) + 0.4.1 / 2018-04-05 ------------------ diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 986e61ed..e6467eab 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -268,6 +268,19 @@ Or with one of the following constructs:: For more, see the `pytest `_ documentation. +Testing on multiple Python versions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +pandas-gbq uses `nox `__ to automate testing in +multiple Python environments. First, install nox. + +.. code-block:: shell + + $ pip install --upgrade nox-automation + +To run tests in all versions of Python, run `nox` from the repository's root +directory. + .. _contributing.gbq_integration_tests: Running Google BigQuery Integration Tests diff --git a/nox.py b/nox.py new file mode 100644 index 00000000..4de95fe9 --- /dev/null +++ b/nox.py @@ -0,0 +1,81 @@ +"""Nox test automation configuration. + +See: https://nox.readthedocs.io/en/latest/ +""" + +import os.path + +import nox + + +PANDAS_PRE_WHEELS = ( + 'https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83' + '.ssl.cf2.rackcdn.com') + + +@nox.session +def default(session): + session.install('mock', 'pytest', 'pytest-cov') + session.install('-e', '.') + session.run( + 'pytest', + os.path.join('pandas_gbq', 'tests'), + '--quiet', + '--cov=pandas_gbq', + '--cov-report', + 'xml:/tmp/pytest-cov.xml', + *session.posargs + ) + + +@nox.session +def test27(session): + session.interpreter = 'python2.7' + session.install( + '-r', os.path.join('.', 'ci', 'requirements-2.7-0.19.2.pip')) + default(session) + + +@nox.session +def test35(session): + session.interpreter = 'python3.5' + session.install( + '-r', os.path.join('.', 'ci', 'requirements-3.5-0.18.1.pip')) + default(session) + + +@nox.session +def test36(session): + session.interpreter = 'python3.6' + session.install( + '-r', os.path.join('.', 'ci', 'requirements-3.6-0.20.1.conda')) + default(session) + + +@nox.session +def test36master(session): + session.interpreter = 'python3.6' + session.install( + '--pre', + '--upgrade', + '--timeout=60', + '-f', PANDAS_PRE_WHEELS, + 'pandas') + session.install( + '-r', os.path.join('.', 'ci', 'requirements-3.6-MASTER.pip')) + default(session) + + +@nox.session +def lint(session): + session.install('flake8') + session.run('flake8', 'pandas_gbq', '-v') + + +@nox.session +def cover(session): + session.interpreter = 'python3.5' + + session.install('coverage', 'pytest-cov') + session.run('coverage', 'report', '--show-missing', '--fail-under=40') + session.run('coverage', 'erase') diff --git a/pandas_gbq/tests/test__query.py b/pandas_gbq/tests/test__query.py index 43ab00f3..09260636 100644 --- a/pandas_gbq/tests/test__query.py +++ b/pandas_gbq/tests/test__query.py @@ -1,7 +1,10 @@ import pkg_resources -import mock +try: + import mock +except ImportError: + from unittest import mock @mock.patch('google.cloud.bigquery.QueryJobConfig') diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..e0e72d7f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +flake8 +google-cloud-bigquery +nox-automation +pandas +pytest +setuptools