1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# -*- coding: utf-8 -*-
"""
Test :: ExifToolHelper - misc tests
"""
# standard
import unittest
from pathlib import Path
# test helpers
from tests.common_util import TEST_IMAGE_JPG
# custom
import exiftool
class HelperInitializationTest(unittest.TestCase):
def test_initialization(self):
"""
Initialization with all arguments at their default values.
this is to test that the constructor passes the right values to the base class (ensure that the class inheritence working as expected even if underlying base class parameters change)
"""
exif_tool_helper = exiftool.ExifToolHelper()
exif_tool_helper.run()
self.assertTrue(exif_tool_helper.running)
exif_tool_helper.terminate()
self.assertFalse(exif_tool_helper.running)
# ---------------------------------------------------------------------------------------------------------
class TestExifToolHelperMisc(unittest.TestCase):
# ---------------------------------------------------------------------------------------------------------
def setUp(self):
self.et = exiftool.ExifToolHelper(common_args=["-G", "-n", "-overwrite_original"])
def tearDown(self):
if self.et.running:
self.et.terminate()
# ---------------------------------------------------------------------------------------------------------
def test_execute_types(self):
""" test execute with different types (exact same as the test with ExifTool, except the last one passes) """
self.assertFalse(self.et.running)
# no error with str
self.et.execute("-ver")
# no error with bytes
self.et.execute(b"-ver")
# no error with str
self.et.execute(str(TEST_IMAGE_JPG))
# error with Path
self.et.execute(Path(TEST_IMAGE_JPG))
# ---------------------------------------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
|