Skip to content

Commit 5884908

Browse files
committed
test clean-up
1 parent 838d2ef commit 5884908

File tree

6 files changed

+92
-142
lines changed

6 files changed

+92
-142
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2019 R.S. Weigel
1+
Copyright 2019, 2020 R.S. Weigel
22

33
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
44

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ PYTHON_VER=$(subst python,,$(PYTHON))
44

55
# Python versions to test
66
# TODO: Use tox.
7-
PYTHONVERS=python2.7 python3.5 python3.6 python3.7 python3.8
7+
PYTHONVERS=python3.8 python3.7 python3.6 python3.5 python2.7
88

99
# VERSION is updated in "make version-update" step and derived
1010
# from CHANGES.txt. Do not edit.
1111
VERSION=0.1.5b4
1212
SHELL:= /bin/bash
1313

14-
LONG_TESTS=false
14+
LONG_TESTS=true
1515

1616
# Select this to have anaconda installed for you.
1717
CONDA=./anaconda3
@@ -132,16 +132,15 @@ repository-test-data:
132132
# 'python setup.py develop' creates symlinks in system package directory.
133133
# $(CONDA_ACTIVATE) $(PYTHON); $(PYTHON) setup.py develop | grep "Best"
134134

135-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v -m 'short' hapiclient/test/test_hapi.py
136-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_hapitime2datetime.py
137-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_hapitime2datetime.py
138-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_hapitime_reformat.py
139-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_chunking.py
140135
ifeq (LONG_TESTS,true)
141136
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v -m 'long' hapiclient/test/test_hapi.py
142-
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v -m 'verylong' hapiclient/test/test_hapi.py
137+
else
138+
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v -m 'short' hapiclient/test/test_hapi.py
143139
endif
144140

141+
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_chunking.py
142+
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_hapitime2datetime.py
143+
$(CONDA_ACTIVATE) $(PYTHON); $(pythonw) -m pytest -v hapiclient/test/test_hapitime_reformat.py
145144
# These require visual inspection.
146145
repository-test-plots:
147146
@make clean
@@ -238,7 +237,7 @@ version-tag:
238237
# Install package in local directory (symlinks made to local dir)
239238
install-local:
240239
# python setup.py -e .
241-
pre = sys._getframe(1).f_code.co_name + '(): '$(CONDA_ACTIVATE) $(PYTHON); pip install --editable .
240+
$(CONDA_ACTIVATE) $(PYTHON); pip install --editable .
242241

243242
install:
244243
pip install 'hapiclient==$(VERSION)' --index-url $(URL)/simple

hapiclient/test/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
markers =
3+
short: Short-running tests
34
long: Long-running test

hapiclient/test/test_chunking.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def cat(d1, d2):
3737
d12.update(d2)
3838
return d12
3939

40+
4041
opts0 = {'logging': hapi_logging, 'usecache': False, 'cache': False}
4142

4243
# Test dict.

hapiclient/test/test_hapi.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
# See comments in test_hapitime2datetime.py for other execution options.
1919

20-
def clearcache(opts):
21-
shutil.rmtree(opts['cachedir'], ignore_errors=True)
22-
23-
2420
def writepickle(fname, var):
2521
print("!!!!!!!!!!!!!!")
2622
print("Writing " + fname)
@@ -121,15 +117,15 @@ def test_reader_short():
121117
opts['cache'] = False
122118

123119
# Read one parameter
124-
clearcache(opts)
120+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
125121
assert readcompare(server, dataset, 'scalar', run, opts)
126122

127123
# Read two parameters
128-
clearcache(opts)
124+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
129125
assert readcompare(server, dataset, 'scalar,vector', run, opts)
130126

131127
# Read all parameters
132-
clearcache(opts)
128+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
133129
assert readcompare(server, dataset, '', run, opts)
134130

135131
#
@@ -138,16 +134,16 @@ def test_reader_short():
138134
opts['cache'] = True
139135

140136
# Read one parameter
141-
clearcache(opts)
137+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
142138
assert readcompare(server, dataset, 'scalar', run, opts)
143139

144140
# Read two parameters
145-
clearcache(opts)
141+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
146142
assert readcompare(server, dataset, 'scalar,vector', run, opts)
147-
clearcache(opts)
143+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
148144

149145
# Read all parameters
150-
clearcache(opts)
146+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
151147
assert readcompare(server, dataset, '', run, opts)
152148

153149

@@ -162,7 +158,7 @@ def test_cache_short():
162158
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': True}
163159

164160
opts['usecache'] = False
165-
clearcache(opts)
161+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
166162
data, meta = hapi(server, dataset, 'scalarint,vectorint', start, stop, **opts)
167163

168164
opts['usecache'] = True
@@ -182,21 +178,21 @@ def test_subset_short():
182178
opts['usecache'] = False
183179

184180
# Request two subsets with empty cache. Common parts should be same.
185-
clearcache(opts)
181+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
186182
data, meta = hapi(server, dataset, 'scalarint', start, stop, **opts)
187183

188-
clearcache(opts)
184+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
189185
data2, meta2 = hapi(server, dataset, 'scalarint,vectorint', start, stop, **opts)
190186

191187
ok = np.array_equal(data['Time'], data2['Time'])
192188
ok = ok and np.array_equal(data['scalarint'], data2['scalarint'])
193189
assert ok
194190

195191
# Request all parameters and single parameter. Common parameter should be same.
196-
clearcache(opts)
192+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
197193
data, meta = hapi(server, dataset, '', start, stop, **opts)
198194

199-
clearcache(opts)
195+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
200196
data2, meta2 = hapi(server, dataset, 'vectorint', start, stop, **opts)
201197

202198
ok = np.array_equal(data['Time'], data2['Time'])
@@ -217,7 +213,7 @@ def test_subset_short():
217213

218214
# Request all parameters and single parameter, with the single parameter
219215
# request using the cache with hot cache. Common parameter should be same.
220-
clearcache(opts)
216+
shutil.rmtree(opts['cachedir'], ignore_errors=True)
221217
data, meta = hapi(server, dataset, '', start, stop, **opts)
222218
data2, meta2 = hapi(server, dataset, 'vectorint', start, stop, **opts)
223219

@@ -232,29 +228,16 @@ def test_reader_long():
232228
dataset = 'dataset1'
233229
run = 'long'
234230

235-
# Read two parameters
231+
# Read three parameters
236232
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': False, 'usecache': False}
237-
assert readcompare(server, dataset, 'scalar,vector', run, opts)
233+
assert readcompare(server, dataset, 'scalar,vector,spectra', run, opts)
238234

239235
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': True, 'usecache': False}
240-
assert readcompare(server, dataset, 'scalar,vector', run, opts)
236+
assert readcompare(server, dataset, 'scalar,vector,spectra', run, opts)
241237

242238
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': False, 'usecache': True}
243-
assert readcompare(server, dataset, 'scalar,vector', run, opts)
244-
245-
246-
@pytest.mark.verylong
247-
def test_reader_very_long():
248-
249-
dataset = 'dataset1'
250-
run = 'verylong'
251-
252-
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': True, 'usecache': False}
253-
assert readcompare(server, dataset, '', run, opts)
254-
255-
opts = {'logging': False, 'cachedir': '/tmp/hapi-data', 'cache': False, 'usecache': True}
256-
assert readcompare(server, dataset, '', run, opts)
239+
assert readcompare(server, dataset, 'scalar,vector,spectra', run, opts)
257240

258241

259242
if __name__ == '__main__':
260-
test_reader_short()
243+
test_reader_long()

0 commit comments

Comments
 (0)