Skip to content

Commit b689760

Browse files
committed
update test matrix
1 parent de225fb commit b689760

File tree

8 files changed

+91
-21
lines changed

8 files changed

+91
-21
lines changed

.travis.yml

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
11
language: python
2-
sudo: false
3-
python:
4-
- "2.7"
5-
- "3.4"
6-
- "3.5"
7-
- "3.6"
2+
dist: xenial
83
env:
9-
matrix:
10-
- DJANGO="django==1.8.18"
11-
- DJANGO="django==1.10.7"
12-
- DJANGO="django==1.11.4"
13-
- DJANGO="django==1.11.4" LINT=1
144
global:
15-
- REST="djangorestframework==3.6.4"
16-
- PANDAS="pandas==0.20.3"
5+
- DJANGO="django==2.1.7"
6+
- REST="djangorestframework==3.9.1"
7+
- PANDAS="pandas==0.24.1"
8+
matrix:
9+
include:
10+
- python: "2.7"
11+
name: "Python 2.7 (Django 1.8)"
12+
env:
13+
- DJANGO="django==1.8.19"
14+
- REST="djangorestframework==3.6.4"
15+
- python: "3.5"
16+
name: "Python 3.5 (Django 1.8)"
17+
env:
18+
- DJANGO="django==1.8.19"
19+
- REST="djangorestframework==3.6.4"
20+
- python: "2.7"
21+
name: "Python 2.7 (Django 1.11)"
22+
env:
23+
- DJANGO="django==1.11.20"
24+
- python: "3.7"
25+
name: "Python 3.7 (Django 1.11)"
26+
env:
27+
- DJANGO="django==1.11.20"
28+
- python: "3.4"
29+
name: "Python 3.4"
30+
env:
31+
- DJANGO="django==2.0.13"
32+
- python: "3.5"
33+
name: "Python 3.5"
34+
env: []
35+
- python: "3.6"
36+
name: "Python 3.6"
37+
env: []
38+
- python: "3.7"
39+
name: "Python 3.7"
40+
env: []
41+
- python: "3.7"
42+
name: "Python 3.7 + matplotlib"
43+
env:
44+
- MATPLOTLIB="matplotlib"
45+
- python: "3.7"
46+
name: "Python 3.7 + django-pandas"
47+
env:
48+
- DJPANDAS="django-pandas"
49+
- python: "3.7"
50+
name: "Code Lint"
51+
env:
52+
- LINT="flake8"
1753
install:
1854
- pip install --upgrade pip
19-
- pip install $DJANGO $REST $PANDAS
20-
- pip install matplotlib
21-
- pip install flake8
22-
- pip install django-pandas
55+
- pip install $DJANGO $REST $PANDAS $MATPLOTLIB $DJPANDAS $LINT
2356
script:
2457
- ./runtests.sh

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def readme():
5656
],
5757
test_suite='tests',
5858
tests_require=[
59-
'wq.io', 'xlwt', 'openpyxl', 'matplotlib',
60-
'django', 'django-mustache'
59+
'wq.io', 'xlwt', 'openpyxl', 'django', 'django-mustache'
6160
],
6261
setup_requires=[
6362
'setuptools_scm',

tests/settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@
1818
'APP_DIRS': True,
1919
},
2020
]
21+
22+
23+
try:
24+
import matplotlib
25+
except ImportError:
26+
HAS_MATPLOTLIB = False
27+
else:
28+
HAS_MATPLOTLIB = True
29+
30+
31+
try:
32+
import django_pandas
33+
except ImportError:
34+
HAS_DJANGO_PANDAS = False
35+
else:
36+
HAS_DJANGO_PANDAS = True

tests/test_complex.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import unittest
12
from rest_framework.test import APITestCase
23
from tests.testapp.models import ComplexTimeSeries
34
from rest_pandas.test import parse_csv
5+
from .settings import HAS_MATPLOTLIB
46

57

68
class ComplexTestCase(APITestCase):
@@ -127,6 +129,7 @@ def test_complex_scatter(self):
127129
]},
128130
], datasets)
129131

132+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
130133
def test_complex_boxplot(self):
131134
# Default group=series-year
132135
response = self.client.get("/complexboxplot.csv")
@@ -179,6 +182,7 @@ def test_complex_boxplot(self):
179182
self.assertEqual(stats['value-mean'], 0.4)
180183
self.assertEqual(stats['value-whishi'], 0.8)
181184

185+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
182186
def test_complex_boxplot_series(self):
183187
response = self.client.get("/complexboxplot.csv?group=series")
184188
datasets = self.parse_csv(response)
@@ -224,6 +228,7 @@ def test_complex_boxplot_series(self):
224228
self.assertEqual(stats['value-mean'], 0.4)
225229
self.assertEqual(stats['value-whishi'], 0.8)
226230

231+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
227232
def test_complex_boxplot_month_group(self):
228233
response = self.client.get("/complexboxplot.csv?group=series-month")
229234
datasets = self.parse_csv(response)
@@ -269,6 +274,7 @@ def test_complex_boxplot_month_group(self):
269274
self.assertEqual(stats['value-mean'], 0.4)
270275
self.assertEqual(stats['value-whishi'], 0.8)
271276

277+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
272278
def test_complex_boxplot_year(self):
273279
response = self.client.get("/complexboxplot.csv?group=year")
274280
datasets = self.parse_csv(response)

tests/test_images.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import unittest
12
from rest_framework.test import APITestCase
23
from tests.testapp.models import TimeSeries
4+
from .settings import HAS_MATPLOTLIB
35

46

7+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
58
class ImageTestCase(APITestCase):
69
def setUp(self):
710
data = (

tests/test_multi.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import unittest
12
from rest_framework.test import APITestCase
23
from tests.testapp.models import MultiTimeSeries
34
from tests.testapp.serializers import NotUnstackableSerializer
45
from rest_pandas.test import parse_csv
56
from django.core.exceptions import ImproperlyConfigured
67
import os
8+
from .settings import HAS_MATPLOTLIB
79

810

911
class MultiTestCase(APITestCase):
@@ -70,7 +72,8 @@ def test_multi_series_html(self):
7072
def test_multi_scatter(self):
7173
response = self.client.get("/multiscatter.csv")
7274
self.assertEqual(
73-
"""date,test1-value,test2-value
75+
""",test1-value,test2-value
76+
date,,
7477
2015-01-01,0.5,0.7
7578
2015-01-02,0.4,0.8
7679
2015-01-03,0.6,0.0
@@ -80,6 +83,7 @@ def test_multi_scatter(self):
8083
response.content.decode('utf-8')
8184
)
8285

86+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
8387
def test_multi_boxplot(self):
8488
# Default: group=series-year
8589
response = self.client.get("/multiboxplot.csv")
@@ -104,6 +108,7 @@ def test_multi_boxplot(self):
104108
self.assertEqual(round(stats['value-mean'], 8), 0.54)
105109
self.assertEqual(stats['value-whishi'], 0.9)
106110

111+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
107112
def test_multi_boxplot_series(self):
108113
response = self.client.get("/multiboxplot.csv?group=series")
109114
datasets = self.parse_csv(response)[0]['data']
@@ -125,6 +130,7 @@ def test_multi_boxplot_series(self):
125130
self.assertEqual(round(stats['value-mean'], 8), 0.54)
126131
self.assertEqual(stats['value-whishi'], 0.9)
127132

133+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
128134
def test_multi_boxplot_series_month(self):
129135
response = self.client.get("/multiboxplot.csv?group=series-month")
130136

@@ -148,6 +154,7 @@ def test_multi_boxplot_series_month(self):
148154
self.assertEqual(round(stats['value-mean'], 8), 0.54)
149155
self.assertEqual(stats['value-whishi'], 0.9)
150156

157+
@unittest.skipUnless(HAS_MATPLOTLIB, "requires matplotlib")
151158
def test_multi_boxplot_year(self):
152159
response = self.client.get("/multiboxplot.csv?group=year")
153160

tests/test_views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import unittest
12
from rest_framework.test import APITestCase
23
from tests.testapp.models import TimeSeries, CustomIndexSeries
34
from wq.io import load_string
45
import json
56
import datetime
67
import os
8+
from .settings import HAS_DJANGO_PANDAS
79

810

911
class PandasTestCase(APITestCase):
@@ -34,6 +36,7 @@ def test_view_csv_noid(self):
3436
self.assertEqual(len(data), 5)
3537
self.assertEqual(data[0].value, '0.5')
3638

39+
@unittest.skipUnless(HAS_DJANGO_PANDAS, 'requires django-pandas')
3740
def test_view_django_pandas(self):
3841
response = self.client.get("/djangopandas.csv")
3942
data = self.load_string(response)

tests/testapp/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from django.db import models
2-
from django_pandas.managers import DataFrameManager
2+
try:
3+
from django_pandas.managers import DataFrameManager
4+
except ImportError:
5+
DataFrameManager = models.Manager
36

47

58
class TimeSeries(models.Model):

0 commit comments

Comments
 (0)