~osomon/pyexiv2/pyexiv2-0.3

86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
4
# ******************************************************************************
5
#
359.1.3 by Olivier Tilloy
Custom DateTimeFormatter helper to convert date/time objects to strings conforming to the EXIF/IPTC/XMP formats.
6
# Copyright (C) 2008-2011 Olivier Tilloy <olivier@tilloy.net>
86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
7
#
8
# This file is part of the pyexiv2 distribution.
9
#
10
# pyexiv2 is free software; you can redistribute it and/or
11
# modify it under the terms of the GNU General Public License
12
# as published by the Free Software Foundation; either version 2
13
# of the License, or (at your option) any later version.
14
#
15
# pyexiv2 is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with pyexiv2; if not, write to the Free Software
22
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
23
#
114 by Olivier Tilloy
Unit tests for the conversion of XMP tags, started fixing the conversion of Dates.
24
# Author: Olivier Tilloy <olivier@tilloy.net>
86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
25
#
26
# ******************************************************************************
27
28
import unittest
29
30
# Test cases to run
270.2.1 by Mark Lee
Port the ReadMetadataTestCase to the 0.2 API.
31
from ReadMetadataTestCase import ReadMetadataTestCase
154 by Olivier Tilloy
Reworked the Rational class.
32
from rational import TestRational
252.1.1 by Olivier Tilloy
GPSCoordinate class to match the XMP GPSCoordinate type.
33
from gps_coordinate import TestGPSCoordinate
197 by Olivier Tilloy
Simplistic implementation of a notifying list to monitor changes to IPTC
34
from notifying_list import TestNotifyingList
148 by Olivier Tilloy
EXIF Short and Short to string conversion.
35
from exif import TestExifTag
36
from iptc import TestIptcTag
334.2.3 by Olivier Tilloy
Unit tests for the custom XMP namespaces.
37
from xmp import TestXmpTag, TestXmpNamespaces
160 by Olivier Tilloy
First version of an ImageMetadata class, meant to replace the Image class.
38
from metadata import TestImageMetadata
280.1.6 by Olivier Tilloy
Unit tests for the exposition of image buffers.
39
from buffer import TestBuffer
281 by Olivier Tilloy
Encode file names in the file system encoding.
40
from encoding import TestEncodings
347.1.1 by Olivier Tilloy
is_fraction and make_fraction: convenience functions to handle transparently
41
from utils import TestConversions, TestFractions
341.1.14 by Olivier Tilloy
Unit test adding comments to an empty image an reading them back.
42
from usercomment import TestUserCommentReadWrite, TestUserCommentAdd
345.1.1 by Olivier Tilloy
Support pickling EXIF tags.
43
from pickling import TestPicklingTags
359.1.3 by Olivier Tilloy
Custom DateTimeFormatter helper to convert date/time objects to strings conforming to the EXIF/IPTC/XMP formats.
44
from datetimeformatter import TestDateTimeFormatter
114 by Olivier Tilloy
Unit tests for the conversion of XMP tags, started fixing the conversion of Dates.
45
86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
46
301.1.2 by Olivier Tilloy
Importable function to run the test suite.
47
def run_unit_tests():
86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
48
    # Instantiate a test suite containing all the test cases
49
    suite = unittest.TestSuite()
270.2.1 by Mark Lee
Port the ReadMetadataTestCase to the 0.2 API.
50
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ReadMetadataTestCase))
154 by Olivier Tilloy
Reworked the Rational class.
51
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRational))
252.1.1 by Olivier Tilloy
GPSCoordinate class to match the XMP GPSCoordinate type.
52
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestGPSCoordinate))
197 by Olivier Tilloy
Simplistic implementation of a notifying list to monitor changes to IPTC
53
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestNotifyingList))
148 by Olivier Tilloy
EXIF Short and Short to string conversion.
54
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestExifTag))
55
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestIptcTag))
114 by Olivier Tilloy
Unit tests for the conversion of XMP tags, started fixing the conversion of Dates.
56
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestXmpTag))
334.2.3 by Olivier Tilloy
Unit tests for the custom XMP namespaces.
57
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestXmpNamespaces))
160 by Olivier Tilloy
First version of an ImageMetadata class, meant to replace the Image class.
58
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestImageMetadata))
280.1.6 by Olivier Tilloy
Unit tests for the exposition of image buffers.
59
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestBuffer))
281 by Olivier Tilloy
Encode file names in the file system encoding.
60
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestEncodings))
327.1.1 by Olivier Tilloy
Strip trailing white spaces in string_to_undefined(…).
61
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestConversions))
347.1.1 by Olivier Tilloy
is_fraction and make_fraction: convenience functions to handle transparently
62
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestFractions))
341.1.14 by Olivier Tilloy
Unit test adding comments to an empty image an reading them back.
63
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestUserCommentReadWrite))
64
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestUserCommentAdd))
345.1.1 by Olivier Tilloy
Support pickling EXIF tags.
65
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestPicklingTags))
359.1.3 by Olivier Tilloy
Custom DateTimeFormatter helper to convert date/time objects to strings conforming to the EXIF/IPTC/XMP formats.
66
    suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestDateTimeFormatter))
86 by Olivier Tilloy
Added some unit tests for basic functionalities. These tests will help spot regressions in the future.
67
    # Run the test suite
301.1.5 by Olivier Tilloy
Return the test runner's result.
68
    return unittest.TextTestRunner(verbosity=2).run(suite)
301.1.2 by Olivier Tilloy
Importable function to run the test suite.
69
70
71
if __name__ == '__main__':
72
    run_unit_tests()
73