Skip to content

Commit

Permalink
Refactor tests so a new instance of a module is given on each run
Browse files Browse the repository at this point in the history
This was making it so changes to the settings of the module in other tests would affect downstream tests
  • Loading branch information
AetherUnbound authored and Matthew Bowden committed May 9, 2018
1 parent ec52f77 commit 1151fbb
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def image(request):
return cellprofiler.image.Image(image=data, dimensions=dimensions)


@pytest.fixture(scope="module")
@pytest.fixture(scope="function")
def image_empty():
image = cellprofiler.image.Image()

Expand Down Expand Up @@ -71,11 +71,12 @@ def measurements():
return cellprofiler.measurement.Measurements()


@pytest.fixture(scope="module")
@pytest.fixture(scope="function")
def module(request):
instance = getattr(request.module, "instance")

return instance
return instance()


@pytest.fixture(scope="function")
def objects(image):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_blobdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def image(request):
return cellprofiler.image.Image(image=data, dimensions=dimensions)


instance = blobdetection.BlobDetection()
instance = blobdetection.BlobDetection


def test_run_dog(image, image_set, module, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edgedetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import edgedetection

instance = edgedetection.EdgeDetection()
instance = edgedetection.EdgeDetection


def test_run_without_mask(image, image_set, module, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gammacorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import gammacorrection

instance = gammacorrection.GammaCorrection()
instance = gammacorrection.GammaCorrection


def test_run(image, module, image_set, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_histogramequalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import histogramequalization

instance = histogramequalization.HistogramEqualization()
instance = histogramequalization.HistogramEqualization


def test_run(image, image_set, module, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_imagegradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import imagegradient

instance = imagegradient.ImageGradient()
instance = imagegradient.ImageGradient


def test_run(image, module, image_set, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_laplacianofgaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import laplacianofgaussian

instance = laplacianofgaussian.LaplacianOfGaussian()
instance = laplacianofgaussian.LaplacianOfGaussian


def test_run(image, image_set, module, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mergeobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mergeobjects


instance = mergeobjects.MergeObjects()
instance = mergeobjects.MergeObjects


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_randomwalkeralgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import randomwalkeralgorithm


instance = randomwalkeralgorithm.RandomWalkerAlgorithm()
instance = randomwalkeralgorithm.RandomWalkerAlgorithm


def test_run(image, module, workspace):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tophattransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import tophattransform

instance = tophattransform.TopHatTransform()
instance = tophattransform.TopHatTransform


@pytest.fixture(
Expand Down

0 comments on commit 1151fbb

Please sign in to comment.