Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Apr 27, 2023
1 parent 7fc0ffe commit 299d87f
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/test_imshowtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,38 @@

from tkinter import Tk
import cv2
from imshowtk.imshowtk import bitmap_to_photo
from imshowtk.imshowtk import bitmap_to_photo, ImshowTk

def test_bitmap_to_photo():
"""bitmap_to_photo runs"""
def test_tk_is_working():
"""On some macos runners TK doesn't get set up properly
We can quickly check for that here.
"""
try:
window = Tk(None)
_ = Tk(None)
except RuntimeError:
#we're getting runtime errors on some macos CI.
#https://github.com/actions/setup-python/issues/649
assert False
return

def test_bitmap_to_photo():
"""bitmap_to_photo runs"""
window = Tk(None)
image = cv2.imread('project-icon.png')
print (image.shape)

_ = bitmap_to_photo(image)
window.destroy()

def test_mmshowtk_not_in_use():
"""imshow does nothing if not in use"""
imshow = ImshowTk(in_use = False)
frame = cv2.imread('project-icon.png')
imshow.imshow(frame)
del imshow

def test_imshowtk_in_use():
"""imshow shows frame when in use"""
imshow = ImshowTk()
frame = cv2.imread('project-icon.png')
imshow.imshow(frame)
del imshow

0 comments on commit 299d87f

Please sign in to comment.