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
global _console
width = 10_000 if OSXPHOTOS_IS_TESTING else None
_console.console = Console(theme=theme, width=width)
_console.console = Console(theme=theme, width=10_000)
# closure to capture timestamp
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 .test_catalina_10_15_7 import UUID_DICT_LOCAL
def get_os_version():
import platform

View File

@ -17,7 +17,6 @@ from tempfile import TemporaryDirectory
import pytest
from click.testing import CliRunner
from conftest import copy_photos_library_to_path
from osxmetadata import OSXMetaData, Tag
import osxphotos
@ -37,6 +36,8 @@ from osxphotos.exiftool import ExifTool, get_exiftool_path
from osxphotos.fileutil import FileUtil
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"
LIVE_PHOTOS_DB = "tests/Test-Cloud-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_9816.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": [
"TestBurst/IMG_9812.JPG",
@ -66,6 +72,11 @@ UUID_BURST_ALBUM = {
"TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.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
# subtract 1 from len because one photo in two albums so shows up twice in the list
assert f"exported: {len(UUID_BURST_ALBUM[uuid]) - 1}" in result.output
assert f"exported: 5" in result.output
# export again with --skip-bursts
result = runner.invoke(

View File

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

View File

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