Skip to content

Commit

Permalink
Merge pull request #26 from danforthcenter/diagnose-test-issues
Browse files Browse the repository at this point in the history
Debug intermittent testing failures
  • Loading branch information
maliagehan authored May 16, 2024
2 parents 142bf93 + 19129c4 commit d0faaee
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr xvfb
sudo apt-get install --no-install-recommends libyaml-dev libegl1-mesa libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 xserver-xephyr
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb ipython anyio
- name: Lint with flake8
Expand All @@ -48,8 +47,9 @@ jobs:
pip uninstall -y opencv-python
pip install opencv-python-headless
- name: Tests
uses: aganders3/headless-gui@v2
uses: aganders3/headless-gui@v2.2
with:
xvfb-screen-size: 1280x720x24
run: pytest --cov-report=xml --cov=./
- name: Upload coverage to Deepsource
uses: deepsourcelabs/test-coverage-action@master
Expand Down
18 changes: 9 additions & 9 deletions tests/test_annotate_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_points(test_data):
img = cv2.imread(test_data.small_rgb_img)

# initialize interactive tool
drawer_rgb = Points(img, figsize=(12, 6))
drawer_rgb = Points(img, figsize=(5, 5))

# simulate mouse clicks
# event 1, left click to add point
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_points_print_coords(test_data, tmpdir):
img = cv2.imread(test_data.small_rgb_img)

# initialize interactive tool
drawer_rgb = Points(img, figsize=(12, 6))
drawer_rgb = Points(img, figsize=(5, 5))

# simulate mouse clicks
# event 1, left click to add point
Expand All @@ -82,7 +82,7 @@ def test_points_import_list(test_data):
# Read in a test image
img = cv2.imread(test_data.small_rgb_img)
# initialize interactive tool
drawer_rgb = Points(img, figsize=(12, 6), label="default")
drawer_rgb = Points(img, figsize=(5, 5), label="default")
totalpoints1 = [(158, 531), (361, 112), (500, 418), (269.25303806488864, 385.69839981447126),
(231.21964288863632, 445.995245825603), (293.37177646934134, 448.778177179963),
(240.49608073650273, 277.1640769944342), (279.4571196975417, 240.05832560296852),
Expand All @@ -98,7 +98,7 @@ def test_points_import_list_warn(test_data):
# Read in a test image
img = cv2.imread(test_data.small_rgb_img)
# initialize interactive tool
drawer_rgb = Points(img, figsize=(12, 6), label="default")
drawer_rgb = Points(img, figsize=(5, 5), label="default")
totalpoints1 = [(158, 531), (361, 112), (500, 418), (445.50535717435065, 138.94515306122452)]
drawer_rgb.import_list(coords=totalpoints1)

Expand All @@ -108,7 +108,7 @@ def test_points_import_list_warn(test_data):
def test_points_import_file(test_data):
"""Test for plantcv-annotate."""
img = cv2.imread(test_data.small_rgb_img)
counter = Points(img, figsize=(8, 6))
counter = Points(img, figsize=(5, 5))
file = test_data.pollen_coords
counter.import_file(file)

Expand All @@ -121,7 +121,7 @@ def test_points_view(test_data):
img = cv2.imread(test_data.small_rgb_img)

# initialize interactive tool
drawer_rgb = Points(img, figsize=(12, 6))
drawer_rgb = Points(img, figsize=(5, 5))

# simulate mouse clicks
# event 1, left click to add point
Expand All @@ -137,7 +137,7 @@ def test_points_view(test_data):
drawer_rgb.onclick(e2)
drawer_rgb.view(view_all=False)

assert str(drawer_rgb.fig) == "Figure(1200x600)"
assert str(drawer_rgb.fig) == "Figure(500x500)"


def test_points_view_warn(test_data):
Expand All @@ -146,7 +146,7 @@ def test_points_view_warn(test_data):
img = cv2.imread(test_data.small_rgb_img)

# initialize interactive tool, implied default label and "r" color
drawer_rgb = Points(img, figsize=(12, 6))
drawer_rgb = Points(img, figsize=(5, 5))

# simulate mouse clicks, event 1=left click to add point
e1 = matplotlib.backend_bases.MouseEvent(name="button_press_event", canvas=drawer_rgb.fig.canvas,
Expand All @@ -156,4 +156,4 @@ def test_points_view_warn(test_data):
drawer_rgb.onclick(e1)
drawer_rgb.view(label="new", color='r')

assert str(drawer_rgb.fig) == "Figure(1200x600)"
assert str(drawer_rgb.fig) == "Figure(500x500)"
1 change: 1 addition & 0 deletions tests/test_napari_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ def test_napari_classes(make_napari_viewer):
keys = napari_classes(viewer)

assert keys == ['total', 'test']
viewer.close()
4 changes: 4 additions & 0 deletions tests/test_napari_join_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def test_napari_join_labels(test_data):
labeled, _ = napari_join_labels(img, viewer)

assert np.shape(labeled) == (576, 537)
viewer.close()


def test_napari_join_allclass(test_data):
Expand All @@ -34,6 +35,7 @@ def test_napari_join_allclass(test_data):
labeled, _ = napari_join_labels(img, viewer)

assert np.shape(labeled) == (576, 537)
viewer.close()


def test_napari_join_warn(test_data):
Expand All @@ -54,6 +56,7 @@ def test_napari_join_warn(test_data):
labeled, _ = napari_join_labels(img, viewer)

assert np.shape(labeled) == (576, 537)
viewer.close()


def test_napari_join_print(test_data, tmpdir):
Expand All @@ -77,3 +80,4 @@ def test_napari_join_print(test_data, tmpdir):
labeled, _ = napari_join_labels(img, viewer)

assert np.shape(labeled) == (576, 537)
viewer.close()
1 change: 1 addition & 0 deletions tests/test_napari_label_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ def test_napari_label_classes_gray(test_data):
face_color="red", size=1)

assert len(viewer.layers['background'].data) == 1
viewer.close()
3 changes: 3 additions & 0 deletions tests/test_napari_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_napari_open_rgb(test_data):
face_color="red", size=1)

assert len(viewer.layers['total'].data) == 2
viewer.close()


def test_napari_open_gray(test_data):
Expand All @@ -25,6 +26,7 @@ def test_napari_open_gray(test_data):
face_color="red", size=1)

assert len(viewer.layers['total'].data) == 2
viewer.close()


def test_napari_open_envi(test_data):
Expand All @@ -38,3 +40,4 @@ def test_napari_open_envi(test_data):
face_color="red", size=1)

assert len(viewer.layers['total'].data) == 2
viewer.close()

0 comments on commit d0faaee

Please sign in to comment.