fix verbose output when redirected to file, #661

This commit is contained in:
Rhet Turnbull 2022-03-27 09:52:23 -07:00
parent 93de53da51
commit 382d097285
6 changed files with 27 additions and 15 deletions

View File

@ -80,8 +80,7 @@ def verbose_print(
return noop return noop
global _console global _console
width = 10_000 if OSXPHOTOS_IS_TESTING else None _console.console = Console(theme=theme, width=10_000)
_console.console = Console(theme=theme, width=width)
# closure to capture timestamp # closure to capture timestamp
def verbose_(*args): def verbose_(*args):

0
tests/__init__.py Normal file
View File

View File

@ -8,6 +8,8 @@ from photoscript.utils import ditto
from osxphotos.exiftool import _ExifToolProc from osxphotos.exiftool import _ExifToolProc
from .test_catalina_10_15_7 import UUID_DICT_LOCAL
def get_os_version(): def get_os_version():
import platform import platform

View File

@ -17,7 +17,6 @@ from tempfile import TemporaryDirectory
import pytest import pytest
from click.testing import CliRunner from click.testing import CliRunner
from conftest import copy_photos_library_to_path
from osxmetadata import OSXMetaData, Tag from osxmetadata import OSXMetaData, Tag
import osxphotos import osxphotos
@ -37,6 +36,8 @@ from osxphotos.exiftool import ExifTool, get_exiftool_path
from osxphotos.fileutil import FileUtil from osxphotos.fileutil import FileUtil
from osxphotos.utils import noop, normalize_fs_path, normalize_unicode from osxphotos.utils import noop, normalize_fs_path, normalize_unicode
from .conftest import copy_photos_library_to_path
CLI_PHOTOS_DB = "tests/Test-10.15.7.photoslibrary" CLI_PHOTOS_DB = "tests/Test-10.15.7.photoslibrary"
LIVE_PHOTOS_DB = "tests/Test-Cloud-10.15.1.photoslibrary" LIVE_PHOTOS_DB = "tests/Test-Cloud-10.15.1.photoslibrary"
RAW_PHOTOS_DB = "tests/Test-RAW-10.15.1.photoslibrary" RAW_PHOTOS_DB = "tests/Test-RAW-10.15.1.photoslibrary"
@ -58,6 +59,11 @@ UUID_BURST_ALBUM = {
"TestBurst/IMG_9815.JPG", "TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.JPG", "TestBurst/IMG_9816.JPG",
"TestBurst2/IMG_9814.JPG", "TestBurst2/IMG_9814.JPG",
"osxphotos/IMG_9812.JPG", # in my personal library, IMG_9812.JPG == "9A5B4CE6-6A9F-4917-95D4-1C98D14FCE4F"
"osxphotos/IMG_9813.JPG",
"osxphotos/IMG_9814.JPG",
"osxphotos/IMG_9815.JPG",
"osxphotos/IMG_9816.JPG",
], ],
"75154738-83AA-4DCD-A913-632D5D1C0FEE": [ "75154738-83AA-4DCD-A913-632D5D1C0FEE": [
"TestBurst/IMG_9812.JPG", "TestBurst/IMG_9812.JPG",
@ -66,6 +72,11 @@ UUID_BURST_ALBUM = {
"TestBurst/IMG_9815.JPG", "TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.JPG", "TestBurst/IMG_9816.JPG",
"TestBurst2/IMG_9814.JPG", "TestBurst2/IMG_9814.JPG",
"osxphotos/IMG_9812.JPG", # in my personal library, IMG_9812.JPG == "9A5B4CE6-6A9F-4917-95D4-1C98D14FCE4F"
"osxphotos/IMG_9813.JPG",
"osxphotos/IMG_9814.JPG",
"osxphotos/IMG_9815.JPG",
"osxphotos/IMG_9816.JPG",
], ],
} }
@ -6456,8 +6467,7 @@ def test_export_burst_uuid():
], ],
) )
assert result.exit_code == 0 assert result.exit_code == 0
# subtract 1 from len because one photo in two albums so shows up twice in the list assert f"exported: 5" in result.output
assert f"exported: {len(UUID_BURST_ALBUM[uuid]) - 1}" in result.output
# export again with --skip-bursts # export again with --skip-bursts
result = runner.invoke( result = runner.invoke(

View File

@ -12,40 +12,40 @@ pytestmark = pytest.mark.skipif(
) )
UUID_DICT = { UUID_DICT = {
"has_adjustments": "C925CFDC-FF2B-4E71-AC9D-C669B6453A8B", # IMG_1929.JPG "has_adjustments": "C925CFDC-FF2B-4E71-AC9D-C669B6453A8B", # IMG_1929.JPG
"no_adjustments": "16A6AF6B-D8FC-4256-AE33-889733E3EEAB", # IMG_9847.JPG "no_adjustments": "16A6AF6B-D8FC-4256-AE33-889733E3EEAB", # IMG_9847.JPG
"live": "8EC216A2-0032-4934-BD3F-04C6259B3304", # IMG_3259.HEIC "live": "8EC216A2-0032-4934-BD3F-04C6259B3304", # IMG_3259.HEIC
} }
UUID_BURSTS = { UUID_BURSTS = {
"9A5B4CE6-6A9F-4917-95D4-1C98D14FCE4F": { "9A5B4CE6-6A9F-4917-95D4-1C98D14FCE4F": {
"selected": False, "selected": False,
"filename": "IMG_9812.JPG", "filename": "IMG_9812.JPG",
"burst_albums": ["TestBurst"], "burst_albums": ["TestBurst", "osxphotos"],
"albums": ["TestBurst"], "albums": ["TestBurst", "osxphotos"],
}, },
"89E235DD-B9AC-4E8D-BDA2-986981CA7582": { "89E235DD-B9AC-4E8D-BDA2-986981CA7582": {
"selected": False, "selected": False,
"filename": "IMG_9813.JPG", "filename": "IMG_9813.JPG",
"burst_albums": ["TestBurst"], "burst_albums": ["TestBurst", "osxphotos"],
"albums": [], "albums": [],
}, },
"75154738-83AA-4DCD-A913-632D5D1C0FEE": { "75154738-83AA-4DCD-A913-632D5D1C0FEE": {
"selected": True, "selected": True,
"filename": "IMG_9814.JPG", "filename": "IMG_9814.JPG",
"burst_albums": ["TestBurst", "TestBurst2"], "burst_albums": ["TestBurst", "TestBurst2", "osxphotos"],
"albums": ["TestBurst2"], "albums": ["TestBurst2"],
}, },
"4A836160-51B2-4E32-907D-ECDDB2CEC657": { "4A836160-51B2-4E32-907D-ECDDB2CEC657": {
"selected": False, "selected": False,
"filename": "IMG_9815.JPG", "filename": "IMG_9815.JPG",
"burst_albums": ["TestBurst"], "burst_albums": ["TestBurst", "osxphotos"],
"albums": [], "albums": [],
}, },
"F5E6BD24-B493-44E9-BDA2-7AD9D2CC8C9D": { "F5E6BD24-B493-44E9-BDA2-7AD9D2CC8C9D": {
"selected": True, "selected": True,
"filename": "IMG_9816.JPG", "filename": "IMG_9816.JPG",
"burst_albums": ["TestBurst"], "burst_albums": ["TestBurst", "osxphotos"],
"albums": [], "albums": [],
}, },
} }

View File

@ -3,7 +3,6 @@ import os
import re import re
import pytest import pytest
from photoinfo_mock import PhotoInfoMock
import osxphotos import osxphotos
from osxphotos.exiftool import get_exiftool_path from osxphotos.exiftool import get_exiftool_path
@ -15,6 +14,8 @@ from osxphotos.phototemplate import (
RenderOptions, RenderOptions,
) )
from .photoinfo_mock import PhotoInfoMock
try: try:
exiftool = get_exiftool_path() exiftool = get_exiftool_path()
except: except: