Skip to content

Commit d5151b7

Browse files
authored
Use 'tox' to run tests (#108)
* Use 'tox' to run tests Allows for testing multiple Pythons. * Update CHANGELOG.rst
1 parent f295d76 commit d5151b7

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ build/
55
dist/
66
.uptodate
77
/.env
8-
/junit.xml
8+
/junit-*.xml
99
/.cache
1010
.ensure-*
11+
/.tox

CHANGELOG.rst

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
Changelog
33
=========
44

5+
0.5.0 (2018-??-??)
6+
==================
7+
8+
New features
9+
------------
10+
11+
* grafanalib now supports Python 2.7. This enables it to be used within `Bazel <https://bazel.build>`_.
12+
* Partial support for graphs against Elasticsearch datasources (https://github.com/weaveworks/grafanalib/pull/99)
13+
14+
Extensions
15+
----------
16+
17+
* Constants for days, hours, and minutes (https://github.com/weaveworks/grafanalib/pull/98)
18+
* Groups and tags can now be used with templates (https://github.com/weaveworks/grafanalib/pull/97)
19+
20+
521
0.4.0 (2017-11-23)
622
==================
723

Makefile

+20-23
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,53 @@ DOCKER_IMAGE_DIRS=$(patsubst %/Dockerfile,%,$(DOCKERFILES))
2323
IMAGE_NAMES=$(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)/%,$(shell basename $(dir))))
2424

2525
# Python-specific stuff
26-
VIRTUALENV_DIR ?= .env
27-
VIRTUALENV_BIN = $(VIRTUALENV_DIR)/bin
28-
DEPS_UPTODATE = $(VIRTUALENV_DIR)/.deps-uptodate
29-
30-
VIRTUALENV := $(shell command -v virtualenv 2> /dev/null)
26+
TOX := $(shell command -v tox 2> /dev/null)
3127
PIP := $(shell command -v pip 2> /dev/null)
28+
FLAKE8 := $(shell command -v flake8 2> /dev/null)
3229

33-
JUNIT_XML := "junit.xml"
34-
35-
.ensure-virtualenv: .ensure-pip
36-
ifndef VIRTUALENV
37-
$(error "virtualenv is not installed. Install with `pip install [--user] virtualenv`.")
30+
.ensure-tox: .ensure-pip
31+
ifndef TOX
32+
rm -f .ensure-tox
33+
$(error "tox is not installed. Install with `pip install [--user] tox`.")
3834
endif
39-
touch .ensure-virtualenv
35+
touch .ensure-tox
4036

4137
.ensure-pip:
4238
ifndef PIP
39+
rm -f .ensure-pip
4340
$(error "pip is not installed. Install with `python -m [--user] ensurepip`.")
4441
endif
4542
touch .ensure-pip
4643

47-
$(VIRTUALENV_BIN)/pip: .ensure-virtualenv
48-
virtualenv $(VIRTUALENV_DIR)
44+
.ensure-flake8: .ensure-pip
45+
ifndef FLAKE8
46+
rm -f .ensure-flake8
47+
$(error "flake8 is not installed. Install with `pip install [--user] flake8`.")
48+
endif
49+
touch .ensure-pip
4950

5051
images:
5152
$(info $(IMAGE_NAMES))
5253

5354
all: $(UPTODATE_FILES) test lint
5455

55-
$(DEPS_UPTODATE): setup.py $(VIRTUALENV_BIN)/pip
56-
$(VIRTUALENV_BIN)/pip install -e .[dev]
57-
touch $(DEPS_UPTODATE)
58-
59-
deps: $(DEPS_UPTODATE)
56+
deps: setup.py .ensure-tox tox.ini
6057

6158
$(VIRTUALENV_BIN)/flake8 $(VIRTUALENV_BIN)/py.test: $(DEPS_UPTODATE)
6259

6360
gfdatasource/$(UPTODATE): gfdatasource/*
6461

65-
lint: $(VIRTUALENV_BIN)/flake8
66-
$(VIRTUALENV_BIN)/flake8 gfdatasource/gfdatasource grafanalib
62+
lint: .ensure-flake8
63+
$(FLAKE8) gfdatasource/gfdatasource grafanalib
6764

68-
test: $(VIRTUALENV_BIN)/py.test
69-
$(VIRTUALENV_BIN)/py.test --junitxml=$(JUNIT_XML)
65+
test: .ensure-tox
66+
$(TOX) --skip-missing-interpreters
7067

7168
clean:
7269
$(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true
7370
rm -rf $(UPTODATE_FILES)
7471
rm -rf grafanalib.egg-info
75-
rm $(DEPS_UPTODATE)
72+
rm -f .ensure-pip .ensure-tox .ensure-flake8
7673
find . -name '*.pyc' | xargs rm
7774

7875
clean-deps:

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Support
129129
This library is in its very early stages. We'll probably make changes that
130130
break backwards compatibility, although we'll try hard not to.
131131

132-
grafanalib works with Python 3.4 and 3.5.
132+
grafanalib works with Python 2.7, 3.4, 3.5, and 3.6.
133133

134134
Developing
135135
==========

circle.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ machine:
99

1010
dependencies:
1111
override:
12+
- pip install tox flake8
1213
- make deps
1314

1415
test:
1516
override:
1617
- "mkdir -p $(dirname $SRCDIR) && cp -r $(pwd)/ $SRCDIR"
1718
- "mkdir -p $CIRCLE_TEST_REPORTS/py.test/"
18-
- cd $SRCDIR; make JUNIT_XML=$CIRCLE_TEST_REPORTS/py.test/junit.xml all
19+
- cd $SRCDIR; make all
20+
- mv $SRCDIR/junit-*.xml $CIRCLE_TEST_REPORTS/py.test/
1921

2022
deployment:
2123
push:

tox.ini

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Tox (https://tox.readthedocs.io/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
envlist = py27, py34, py35, py36
8+
9+
[testenv]
10+
commands = pytest --junitxml=junit-{envname}.xml
11+
deps =
12+
pytest

0 commit comments

Comments
 (0)