Skip to content

Commit e5ccb00

Browse files
Improved gphoto version checks
1 parent 8def852 commit e5ccb00

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/test_context.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
class TestContext(unittest.TestCase):
3636
def setUp(self):
3737
use_vcam(True)
38+
self.gp_library_version = tuple(int(x) for x in gp.gp_library_version(
39+
gp.GP_VERSION_SHORT)[0].split('.'))
3840

3941
def cb_idle(self, context, data):
4042
self.callback_count['cb_idle'] += 1
@@ -98,7 +100,7 @@ def test_oo_style(self):
98100
# call some camera functions which may invoke some callbacks
99101
text = camera.get_summary(context)
100102
config = camera.get_config(context)
101-
if gp.gp_library_version(gp.GP_VERSION_SHORT)[0] == '2.5.32':
103+
if self.gp_library_version == (2, 5, 32):
102104
# workaround for https://github.com/gphoto/libgphoto2/issues/1136
103105
camera.folder_list_folders('/store_00010001')
104106
path = camera.capture(gp.GP_CAPTURE_IMAGE, context)
@@ -109,7 +111,7 @@ def test_oo_style(self):
109111
# check result
110112
self.assertEqual(self.callback_count['cb_progress_start'], 1)
111113
self.assertEqual(self.callback_count['cb_progress_stop'], 1)
112-
if gp.gp_library_version(gp.GP_VERSION_SHORT)[0] == '2.5.32':
114+
if self.gp_library_version >= (2, 5, 32):
113115
self.assertEqual(self.callback_count['cb_progress_update'], 21)
114116
self.assertEqual(self.callback_count['cb_cancel'], 31)
115117
else:
@@ -148,7 +150,7 @@ def test_c_style(self):
148150
self.assertEqual(OK, gp.GP_OK)
149151
OK, config = gp.gp_camera_get_config(camera, context)
150152
self.assertEqual(OK, gp.GP_OK)
151-
if gp.gp_library_version(gp.GP_VERSION_SHORT)[0] == '2.5.32':
153+
if self.gp_library_version == (2, 5, 32):
152154
# workaround for https://github.com/gphoto/libgphoto2/issues/1136
153155
camera.folder_list_folders('/store_00010001')
154156
OK, path = gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE, context)
@@ -162,7 +164,7 @@ def test_c_style(self):
162164
# check result
163165
self.assertEqual(self.callback_count['cb_progress_start'], 1)
164166
self.assertEqual(self.callback_count['cb_progress_stop'], 1)
165-
if gp.gp_library_version(gp.GP_VERSION_SHORT)[0] == '2.5.32':
167+
if self.gp_library_version >= (2, 5, 32):
166168
self.assertEqual(self.callback_count['cb_progress_update'], 21)
167169
self.assertEqual(self.callback_count['cb_cancel'], 31)
168170
else:

0 commit comments

Comments
 (0)