Skip to content

Commit cded28d

Browse files
Add tests of attribute equivalence and deletion
1 parent 9c59f4a commit cded28d

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

tests/test_tags.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## python-exiv2 - Python interface to libexiv2
22
## http://github.com/jim-easterbrook/python-exiv2
3-
## Copyright (C) 2023-24 Jim Easterbrook jim@jim-easterbrook.me.uk
3+
## Copyright (C) 2023-25 Jim Easterbrook jim@jim-easterbrook.me.uk
44
##
55
## This program is free software: you can redistribute it and/or
66
## modify it under the terms of the GNU General Public License as
@@ -69,6 +69,12 @@ def test_GroupInfo(self):
6969
self.assertIsInstance(tag_list, list)
7070
self.assertGreater(len(tag_list), 0)
7171
self.assertIsInstance(tag_list[0], exiv2.TagInfo)
72+
self.check_result(info.groupName_, str, info['groupName'])
73+
self.check_result(info.ifdName_, str, info['ifdName'])
74+
with self.assertRaises(TypeError):
75+
del info['groupName']
76+
with self.assertRaises(AttributeError):
77+
del info.ifdName_
7278

7379
def test_TagInfo(self):
7480
info = exiv2.ExifTags.tagList(self.group_name)[0]
@@ -90,6 +96,12 @@ def test_TagInfo(self):
9096
self.check_result(info['title'], str, 'Processing Software')
9197
self.check_result(
9298
info['typeId'], exiv2.TypeId, exiv2.TypeId.asciiString)
99+
self.check_result(info.name_, str, info['name'])
100+
self.check_result(info.title_, str, info['title'])
101+
with self.assertRaises(TypeError):
102+
del info['name']
103+
with self.assertRaises(AttributeError):
104+
del info.title_
93105

94106
def test_ExifKey(self):
95107
# constructors

tests/test_value.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ def test_Date(self):
354354
self.assertEqual(value.day, today.day)
355355
self.assertEqual(dict(value), {
356356
'year': today.year, 'month': today.month, 'day': today.day})
357+
value['day'] = 1
358+
with self.assertRaises(TypeError):
359+
del value['day']
360+
with self.assertRaises(TypeError):
361+
del value.day
357362

358363
def do_test_DateValue(self, py_date):
359364
data = bytes(py_date.strftime('%Y%m%d'), 'ascii')
@@ -415,6 +420,11 @@ def test_Time(self):
415420
self.assertEqual(dict(value), {
416421
'hour': now.hour, 'minute': now.minute, 'second': now.second,
417422
'tzHour': 1, 'tzMinute': 30})
423+
value['second'] = 1
424+
with self.assertRaises(TypeError):
425+
del value['second']
426+
with self.assertRaises(TypeError):
427+
del value.second
418428

419429
def do_test_TimeValue(self, py_time):
420430
exiv_time = exiv2.Time()

0 commit comments

Comments
 (0)