aboutsummaryrefslogtreecommitdiffstats
path: root/test/iptc.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-11-21 20:06:32 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-11-21 20:06:32 +0100
commitd06097e392835a382798d40b5e347262f1f9b95f (patch)
tree050cfc0d877991678fa60cce59297c795a7fd76a /test/iptc.py
parent59a47104d5c6bf6ad94e7f54707c8ac4bf0a84ea (diff)
downloadpyexiv2-d06097e392835a382798d40b5e347262f1f9b95f.tar.gz
Unit test to check that accessing the .raw_values and .values properties issue deprecation warnings.
Diffstat (limited to 'test/iptc.py')
-rw-r--r--test/iptc.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/iptc.py b/test/iptc.py
index 79bc609..ead0f47 100644
--- a/test/iptc.py
+++ b/test/iptc.py
@@ -30,6 +30,7 @@ from pyexiv2.iptc import IptcTag, IptcValueError
from pyexiv2.utils import FixedOffset
import datetime
+import warnings
class TestIptcTag(unittest.TestCase):
@@ -200,3 +201,32 @@ class TestIptcTag(unittest.TestCase):
values = [datetime.date.today(), datetime.date.today()]
self.failUnlessRaises(KeyError, tag._set_values, values)
+ def test_deprecated_properties(self):
+ # The .raw_values and .values properties are deprecated in favour of
+ # .raw_value and .value. Check that they still work for backward
+ # compatibility and that they issue a deprecation warning.
+ # See https://launchpad.net/bugs/617557.
+ tag = IptcTag('Iptc.Application2.City', ['Barcelona'])
+ raw_value = tag.raw_value
+ value = tag.value
+
+ with warnings.catch_warnings(record=True) as w:
+ # Cause all warnings to always be triggered.
+ warnings.simplefilter('always')
+
+ self.assertEqual(tag.raw_values, raw_value)
+ self.assertEqual(len(w), 1)
+ self.assert_(issubclass(w[-1].category, DeprecationWarning))
+
+ self.assertEqual(tag.values, value)
+ self.assertEqual(len(w), 2)
+ self.assert_(issubclass(w[-1].category, DeprecationWarning))
+
+ tag.raw_values = ['Madrid']
+ self.assertEqual(len(w), 3)
+ self.assert_(issubclass(w[-1].category, DeprecationWarning))
+
+ tag.values = ['Madrid']
+ self.assertEqual(len(w), 4)
+ self.assert_(issubclass(w[-1].category, DeprecationWarning))
+