Added tests for utils
This commit is contained in:
@@ -26,6 +26,15 @@ if not _DEBUG:
|
||||
logging.disable(logging.DEBUG)
|
||||
|
||||
|
||||
def _get_logger():
|
||||
"""Used only for testing
|
||||
|
||||
Returns:
|
||||
logging.Logger object -- logging.Logger object for osxphotos
|
||||
"""
|
||||
return logging.Logger(__name__)
|
||||
|
||||
|
||||
def _debug(debug):
|
||||
""" Enable or disable debug logging """
|
||||
if debug:
|
||||
|
||||
40
tests/test_utils.py
Normal file
40
tests/test_utils.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def test_debug_enable():
|
||||
import osxphotos
|
||||
import logging
|
||||
|
||||
osxphotos._debug(True)
|
||||
logger = osxphotos._get_logger()
|
||||
logging.warning(logger)
|
||||
assert logger.isEnabledFor(logging.DEBUG)
|
||||
|
||||
|
||||
def test_debug_disable():
|
||||
import osxphotos
|
||||
import logging
|
||||
|
||||
osxphotos._debug(False)
|
||||
logger = osxphotos._get_logger()
|
||||
logging.warning(logger)
|
||||
assert not logger.isEnabledFor(logging.DEBUG)
|
||||
|
||||
|
||||
def test_dd_to_dms():
|
||||
# expands coverage for edge case in _dd_to_dms
|
||||
from osxphotos.utils import _dd_to_dms
|
||||
|
||||
assert _dd_to_dms(-0.001) == (0, 0, -3.6)
|
||||
|
||||
|
||||
def test_get_system_library_path():
|
||||
import osxphotos
|
||||
|
||||
_, major, _ = osxphotos.utils._get_os_version()
|
||||
if int(major) < 15:
|
||||
with pytest.raises(Exception):
|
||||
assert osxphotos.utils.get_system_library_path()
|
||||
else:
|
||||
assert osxphotos.utils.get_system_library_path() is not None
|
||||
|
||||
Reference in New Issue
Block a user