Skip to content

Commit

Permalink
Merge pull request #1386 from girder/adjust-tests
Browse files Browse the repository at this point in the history
Adjust tests to not clear tile source cache unless needed
  • Loading branch information
manthey authored Nov 25, 2023
2 parents 8003551 + 718f699 commit 8600b72
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion large_image/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# For tilesources. These are also limited by available file handles.
# 'python' cache can use 1/(val) of the available memory based on a very
# rough estimate of the amount of memory used by a tilesource
'cache_tilesource_memory_portion': 8,
'cache_tilesource_memory_portion': 16,
# If >0, this is the maximum number of tilesources that will be cached
'cache_tilesource_maximum': 0,

Expand Down
9 changes: 0 additions & 9 deletions test/test_source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import pytest

import large_image
from large_image.cache_util import cachesClear
from large_image.tilesource import nearPowerOfTwo

from . import utilities
Expand Down Expand Up @@ -170,8 +169,6 @@ def testSourcesCanRead(filename, source):
mod = sys.modules[sourceClass.__module__]
assert bool(mod.canRead(imagePath)) is bool(canRead)

cachesClear()


@pytest.mark.parametrize(('filename', 'source'), sourceAndRegistry())
def testSourcesCanReadPath(filename, source):
Expand All @@ -184,8 +181,6 @@ def testSourcesCanReadPath(filename, source):
sourceClass = large_image.tilesource.AvailableTileSources[source]
assert bool(sourceClass.canRead(Path(imagePath))) is bool(canRead)

cachesClear()


@pytest.mark.parametrize(('filename', 'source'), sourceAndRegistry(True))
def testSourcesTilesAndMethods(filename, source):
Expand Down Expand Up @@ -223,8 +218,6 @@ def testSourcesTilesAndMethods(filename, source):
mod = sys.modules[sourceClass.__module__]
assert mod.open(imagePath) is not None

cachesClear()


@pytest.mark.parametrize(('filename', 'isgeo'), [
('04091217_ruc.nc', True),
Expand All @@ -237,8 +230,6 @@ def testIsGeospatial(filename, isgeo):
imagePath = datastore.fetch(filename)
assert large_image.tilesource.isGeospatial(imagePath) == isgeo

cachesClear()


@pytest.mark.parametrize('palette', [
['#000', '#FFF'],
Expand Down
8 changes: 0 additions & 8 deletions test/test_source_bioformats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from large_image.cache_util import cachesClear

from . import utilities
from .datastore import datastore

Expand All @@ -19,9 +17,6 @@ def testTilesFromBioformats():
# assert tileMetadata['magnification'] == pytest.approx(20, 1)
utilities.checkTilesZXY(source, tileMetadata)

source = None
cachesClear()


def testInternalMetadata():
import large_image_source_bioformats
Expand All @@ -30,6 +25,3 @@ def testInternalMetadata():
source = large_image_source_bioformats.open(imagePath)
metadata = source.getInternalMetadata()
assert 'sizeColorPlanes' in metadata

source = None
cachesClear()
5 changes: 0 additions & 5 deletions test/test_source_dicomweb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import pytest

from large_image.cache_util import cachesClear

from . import utilities


Expand All @@ -27,6 +25,3 @@ def testTilesFromDICOMweb():
assert tileMetadata['levels'] == 9

utilities.checkTilesZXY(source, tileMetadata)

source = None
cachesClear()
14 changes: 5 additions & 9 deletions test/test_source_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import pytest

import large_image
from large_image.cache_util import cachesClear

possible_axes = {
'x': [1, 10],
'y': [1, 10],
'c': [1, 100],
'z': [1, 100],
't': [1, 100],
'p': [1, 100],
'q': [1, 100],
'c': [1, 40],
'z': [1, 40],
't': [1, 40],
'p': [1, 20],
'q': [1, 20],
's': [3, 3],
}

Expand Down Expand Up @@ -191,9 +190,6 @@ def testImageGeneration(data_range):
# assert numpy.array_equal(result, resultFromFile)
print(f'Success; result matrix {result.shape} equals expected matrix {expected.shape}.')

source = None
cachesClear()


if __name__ == '__main__':
testImageGeneration(None)
2 changes: 2 additions & 0 deletions test/test_source_openjpeg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import large_image_source_openjpeg
import pytest

from . import utilities
from .datastore import datastore
Expand Down Expand Up @@ -30,6 +31,7 @@ def testAssociatedImagesFromOpenJPEG():
assert source.getAssociatedImage('nosuchimage') is None


@pytest.mark.singular()
def testBelowLevelTilesFromOpenJPEG():
from large_image.cache_util import cachesClear

Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ allowlist_externals =
commands =
rm -rf build/test/coverage/web_temp
girder build --dev
pytest --numprocesses 1 -m 'singular' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses 0 -m 'singular' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses logical -m 'not singular and not notebook' --cov-config tox.ini --cov-append --suppress-no-test-exit-code {posargs}
- npx nyc report --temp-dir build/test/coverage/web_temp --report-dir build/test/coverage --reporter cobertura --reporter text-summary
# Reduce npm chatter
Expand Down Expand Up @@ -75,7 +75,7 @@ setenv = {[testenv:test]setenv}
description = Run all tests except Girder client
deps = {[testenv:test]deps}
commands =
pytest --numprocesses 1 -m 'singular and not girder_client' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses 0 -m 'singular and not girder_client' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses logical -m 'not singular and not girder_client' --cov-config tox.ini --cov-append --suppress-no-test-exit-code {posargs}

[testenv:server-py{38,39,310,311,312}]
Expand All @@ -97,7 +97,7 @@ deps =
pytest-rerunfailures
pytest-xdist
commands =
pytest --numprocesses 1 -m 'singular and not girder' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses 0 -m 'singular and not girder' --cov-config tox.ini --suppress-no-test-exit-code {posargs}
pytest --numprocesses logical -m 'not singular and not girder and not notebook' --cov-config tox.ini --cov-append --suppress-no-test-exit-code {posargs}

[testenv:core-py{38,39,310,311,312}]
Expand All @@ -117,7 +117,7 @@ deps =
pytest-rerunfailures
pytest-xdist
commands =
pytest --numprocesses 1 -m 'notebook' --no-cov --suppress-no-test-exit-code test/test_notebooks.py {posargs}
pytest --numprocesses 0 -m 'notebook' --no-cov --suppress-no-test-exit-code test/test_notebooks.py {posargs}
setenv =
PIP_FIND_LINKS=https://girder.github.io/large_image_wheels
GDAL_PAM_ENABLED=no
Expand Down

0 comments on commit 8600b72

Please sign in to comment.