Make tests work locally and fix CI configuration
This commit is contained in:
Родитель
664cda126a
Коммит
d9e5158996
156
.travis.yml
156
.travis.yml
|
@ -1,154 +1,22 @@
|
|||
# We set the language to c because python isn't supported on the MacOS X nodes
|
||||
# on Travis. However, the language ends up being irrelevant anyway, since we
|
||||
# install Python ourselves using conda.
|
||||
language: c
|
||||
|
||||
os:
|
||||
- linux
|
||||
|
||||
# Setting sudo to false opts in to Travis-CI container-based builds.
|
||||
sudo: false
|
||||
|
||||
# The apt packages below are needed for sphinx builds. A full list of packages
|
||||
# that can be included can be found here:
|
||||
#
|
||||
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- graphviz
|
||||
- texlive-latex-extra
|
||||
- dvipng
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
env:
|
||||
global:
|
||||
|
||||
# The following versions are the 'default' for tests, unless
|
||||
# overridden underneath. They are defined here in order to save having
|
||||
# to repeat them for all configurations.
|
||||
- PYTHON_VERSION=3.6
|
||||
- NUMPY_VERSION=stable
|
||||
- ASTROPY_VERSION=stable
|
||||
- MAIN_CMD='python setup.py'
|
||||
- SETUP_CMD='test'
|
||||
- PIP_DEPENDENCIES=''
|
||||
- EVENT_TYPE='pull_request push'
|
||||
|
||||
|
||||
# For this package-template, we include examples of Cython modules,
|
||||
# so Cython is required for testing. If your package does not include
|
||||
# Cython code, you can set CONDA_DEPENDENCIES=''
|
||||
- CONDA_DEPENDENCIES='Cython'
|
||||
|
||||
# List other runtime dependencies for the package that are available as
|
||||
# pip packages here.
|
||||
# - PIP_DEPENDENCIES=''
|
||||
|
||||
# Conda packages for affiliated packages are hosted in channel
|
||||
# "astropy" while builds for astropy LTS with recent numpy versions
|
||||
# are in astropy-ci-extras. If your package uses either of these,
|
||||
# add the channels to CONDA_CHANNELS along with any other channels
|
||||
# you want to use.
|
||||
- CONDA_CHANNELS='astropy-ci-extras astropy'
|
||||
|
||||
# If there are matplotlib or other GUI tests, uncomment the following
|
||||
# line to use the X virtual framebuffer.
|
||||
# - SETUP_XVFB=True
|
||||
|
||||
matrix:
|
||||
# Make sure that egg_info works without dependencies
|
||||
- PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
|
||||
- PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
|
||||
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
|
||||
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'
|
||||
|
||||
matrix:
|
||||
|
||||
# Don't wait for allowed failures
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
# Try MacOS X
|
||||
- os: osx
|
||||
env: SETUP_CMD='test'
|
||||
|
||||
# Do a coverage test.
|
||||
- os: linux
|
||||
env: SETUP_CMD='test --coverage'
|
||||
|
||||
# Check for sphinx doc build warnings - we do this first because it
|
||||
# may run for a long time
|
||||
- os: linux
|
||||
env: SETUP_CMD='build_docs -w'
|
||||
|
||||
# Now try Astropy dev with the latest Python and LTS with Python 2.7 and 3.x.
|
||||
- os: linux
|
||||
env: ASTROPY_VERSION=development
|
||||
EVENT_TYPE='pull_request push cron'
|
||||
- os: linux
|
||||
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=lts
|
||||
- os: linux
|
||||
env: ASTROPY_VERSION=lts
|
||||
|
||||
# Try all python versions and Numpy versions. Since we can assume that
|
||||
# the Numpy developers have taken care of testing Numpy with different
|
||||
# versions of Python, we can vary Python and Numpy versions at the same
|
||||
# time.
|
||||
|
||||
- os: linux
|
||||
env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.9
|
||||
- os: linux
|
||||
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.10
|
||||
- os: linux
|
||||
env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.11
|
||||
- os: linux
|
||||
env: NUMPY_VERSION=1.12
|
||||
|
||||
# Try numpy pre-release
|
||||
- os: linux
|
||||
env: NUMPY_VERSION=prerelease
|
||||
EVENT_TYPE='pull_request push cron'
|
||||
|
||||
# Do a PEP8 test with pycodestyle
|
||||
- os: linux
|
||||
env: MAIN_CMD='pycodestyle packagename --count' SETUP_CMD=''
|
||||
|
||||
allow_failures:
|
||||
# Do a PEP8 test with pycodestyle
|
||||
# (allow to fail unless your code completely compliant)
|
||||
- os: linux
|
||||
env: MAIN_CMD='pycodestyle packagename --count' SETUP_CMD=''
|
||||
global:
|
||||
- SETUP_XVFB=True
|
||||
- CONDA_DEPENDENCIES="astropy qtpy pyqt pytest"
|
||||
matrix:
|
||||
- PYTHON_VERSION=2.7
|
||||
- PYTHON_VERSION=3.5
|
||||
- PYTHON_VERSION=3.6
|
||||
|
||||
install:
|
||||
|
||||
# We now use the ci-helpers package to set up our testing environment.
|
||||
# This is done by using Miniconda and then using conda and pip to install
|
||||
# dependencies. Which dependencies are installed using conda and pip is
|
||||
# determined by the CONDA_DEPENDENCIES and PIP_DEPENDENCIES variables,
|
||||
# which should be space-delimited lists of package names. See the README
|
||||
# in https://github.com/astropy/ci-helpers for information about the full
|
||||
# list of environment variables that can be used to customize your
|
||||
# environment. In some cases, ci-helpers may not offer enough flexibility
|
||||
# in how to install a package, in which case you can have additional
|
||||
# commands in the install: section below.
|
||||
|
||||
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
|
||||
- source ci-helpers/travis/setup_conda.sh
|
||||
|
||||
# As described above, using ci-helpers, you should be able to set up an
|
||||
# environment with dependencies installed using conda and pip, but in some
|
||||
# cases this may not provide enough flexibility in how to install a
|
||||
# specific dependency (and it will not be able to install non-Python
|
||||
# dependencies). Therefore, you can also include commands below (as
|
||||
# well as at the start of the install section or in the before_install
|
||||
# section if they are needed before setting up conda) to install any
|
||||
# other dependencies.
|
||||
- git clone git://github.com/astropy/ci-helpers.git
|
||||
- source ci-helpers/travis/setup_conda.sh
|
||||
|
||||
script:
|
||||
- $MAIN_CMD $SETUP_CMD
|
||||
|
||||
after_success:
|
||||
# If coveralls.io is set up for this package, uncomment the line below.
|
||||
# The coveragerc file may be customized as needed for your package.
|
||||
# - if [[ $SETUP_CMD == *coverage* ]]; then coveralls --rcfile='packagename/tests/coveragerc'; fi
|
||||
- py.test pywwt_web
|
||||
|
|
27
appveyor.yml
27
appveyor.yml
|
@ -11,42 +11,23 @@ environment:
|
|||
# of 32 bit and 64 bit builds are needed, move this
|
||||
# to the matrix section.
|
||||
|
||||
# For this package-template, we include examples of Cython modules,
|
||||
# so Cython is required for testing. If your package does not include
|
||||
# Cython code, you can set CONDA_DEPENDENCIES=''
|
||||
CONDA_DEPENDENCIES: "Cython"
|
||||
|
||||
# Conda packages for affiliated packages are hosted in channel
|
||||
# "astropy" while builds for astropy LTS with recent numpy versions
|
||||
# are in astropy-ci-extras. If your package uses either of these,
|
||||
# add the channels to CONDA_CHANNELS along with any other channels
|
||||
# you want to use.
|
||||
# CONDA_CHANNELS: "astropy-ci-extras astropy"
|
||||
CONDA_DEPENDENCIES: "astropy qtpy pyqt pytest"
|
||||
|
||||
matrix:
|
||||
|
||||
# We test Python 2.7 and 3.6 because 2.7 is the supported Python 2
|
||||
# release of Astropy and Python 3.6 is the latest Python 3 release.
|
||||
|
||||
- PYTHON_VERSION: "2.7"
|
||||
ASTROPY_VERSION: "stable"
|
||||
NUMPY_VERSION: "stable"
|
||||
|
||||
- PYTHON_VERSION: "3.5"
|
||||
- PYTHON_VERSION: "3.6"
|
||||
ASTROPY_VERSION: "stable"
|
||||
NUMPY_VERSION: "stable"
|
||||
|
||||
platform:
|
||||
-x64
|
||||
|
||||
install:
|
||||
- "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
|
||||
- "git clone git://github.com/astropy/ci-helpers.git"
|
||||
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
|
||||
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
|
||||
- "activate test"
|
||||
|
||||
# Not a .NET project, we build the package in the install step instead
|
||||
build: false
|
||||
|
||||
test_script:
|
||||
- "%CMD_IN_ENV% python setup.py test"
|
||||
- "%CMD_IN_ENV% py.test pywwt_web"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
import logging
|
||||
|
||||
logger = logging.getLogger('pywwt_web')
|
|
@ -12,6 +12,7 @@ from qtpy.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, WEBENGINE
|
|||
from qtpy import QtWidgets, QtCore
|
||||
|
||||
from .core import BaseWWTWidget
|
||||
from .logger import logger
|
||||
|
||||
__all__ = ['WWTQtWidget']
|
||||
|
||||
|
@ -109,20 +110,25 @@ class CoreWWTQtWidget(QtWidgets.QWidget):
|
|||
if not js:
|
||||
return
|
||||
if self._wwt_ready:
|
||||
print('Running javascript: %s' % js)
|
||||
logger.debug('Running javascript: %s' % js)
|
||||
return self.page.runJavaScript(js)
|
||||
else:
|
||||
print('Caching javascript: %s' % js)
|
||||
logger.debug('Caching javascript: %s' % js)
|
||||
self._js_queue += js + '\n'
|
||||
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class WWTQtWidget(BaseWWTWidget):
|
||||
|
||||
def __init__(self, block_until_ready=False):
|
||||
super(WWTQtWidget, self).__init__()
|
||||
app = QtWidgets.QApplication.instance()
|
||||
global app
|
||||
if app is None:
|
||||
app = QtWidgets.QApplication([''])
|
||||
app = QtWidgets.QApplication.instance()
|
||||
if app is None:
|
||||
app = QtWidgets.QApplication([''])
|
||||
self.widget = CoreWWTQtWidget()
|
||||
self.widget.show()
|
||||
if block_until_ready:
|
||||
|
|
|
@ -1,13 +1,34 @@
|
|||
import time
|
||||
|
||||
from astropy.coordinates import SkyCoord
|
||||
from astropy import units as u
|
||||
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
from ..qt_widget import WWTQtWidget
|
||||
|
||||
M42 = SkyCoord.from_name('M42')
|
||||
|
||||
|
||||
def test_init(self):
|
||||
def wait_and_check_output(seconds, capsys):
|
||||
|
||||
# TODO: would be nice to find a way to do this that doesn't
|
||||
# rely on waiting a fixed number of seconds
|
||||
|
||||
app = QApplication.instance()
|
||||
|
||||
time1 = time.time()
|
||||
while time.time() - time1 < seconds:
|
||||
app.processEvents()
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
assert out.strip() == ""
|
||||
assert err.strip() == ""
|
||||
|
||||
|
||||
def test_init(capsys):
|
||||
WWTQtWidget(block_until_ready=True)
|
||||
wait_and_check_output(1, capsys)
|
||||
|
||||
|
||||
class TestWWTWidget:
|
||||
|
@ -15,14 +36,17 @@ class TestWWTWidget:
|
|||
def setup_class(self):
|
||||
self.widget = WWTQtWidget(block_until_ready=True)
|
||||
|
||||
def test_settings(self):
|
||||
def test_settings(self, capsys):
|
||||
self.widget.constellation_figures = True
|
||||
self.widget.constellation_figures = False
|
||||
wait_and_check_output(1, capsys)
|
||||
|
||||
def test_methods(self):
|
||||
def test_methods(self, capsys):
|
||||
self.widget.center_on_coordinates(M42, fov=10 * u.deg)
|
||||
wait_and_check_output(1, capsys)
|
||||
|
||||
def test_annotations(self):
|
||||
def test_annotations(self, capsys):
|
||||
circle = self.widget.create_circle()
|
||||
circle.opacity = 0.8
|
||||
circle.set_center(M42)
|
||||
wait_and_check_output(1, capsys)
|
||||
|
|
5
setup.py
5
setup.py
|
@ -80,9 +80,9 @@ class NPM(Command):
|
|||
npmName = 'npm';
|
||||
if platform.system() == 'Windows':
|
||||
npmName = 'npm.cmd';
|
||||
|
||||
|
||||
return npmName;
|
||||
|
||||
|
||||
def has_npm(self):
|
||||
npmName = self.get_npm_name();
|
||||
try:
|
||||
|
@ -139,6 +139,7 @@ setup_args = {
|
|||
],
|
||||
'install_requires': [
|
||||
'ipywidgets>=7.0.0',
|
||||
'astropy'
|
||||
],
|
||||
'packages': find_packages(),
|
||||
'zip_safe': False,
|
||||
|
|
Загрузка…
Ссылка в новой задаче