Tests: Add tests for image format saving and loading #104442

Closed
Jesse Yurkovich wants to merge 6 commits from deadpin:image-tests into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 54 additions and 88 deletions
Showing only changes of commit a19dc3c8cb - Show all commits

View File

@ -8,10 +8,9 @@ import unittest
import bpy
sys.path.append(str(pathlib.Path(__file__).parent.absolute()))
deadpin marked this conversation as resolved

We're trying to move away from os.path towards pathlib. I think removing the few usages in the new code in this patch is relatively straightforward.

We're trying to move away from os.path towards pathlib. I think removing the few usages in the new code in this patch is relatively straightforward.
from modules.imbuf_test import (
print_message,
AbstractImBufTest
)
from modules.colored_print import print_message
from modules.imbuf_test import AbstractImBufTest
args = None

View File

@ -7,10 +7,9 @@ import unittest
import bpy
sys.path.append(str(pathlib.Path(__file__).parent.absolute()))
from modules.imbuf_test import (
print_message,
AbstractImBufTest
)
from modules.colored_print import print_message
from modules.imbuf_test import AbstractImBufTest
args = None

View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import sys
class COLORS_ANSI:
RED = '\033[00;31m'
GREEN = '\033[00;32m'
ENDC = '\033[0m'
class COLORS_NONE:
RED = ''
GREEN = ''
ENDC = ''
COLORS = COLORS_NONE
def use_message_colors():
global COLORS, COLORS_ANSI
COLORS = COLORS_ANSI
def print_message(message, type=None, status=''):
if type == 'SUCCESS':
print(COLORS.GREEN, end="")
elif type == 'FAILURE':
print(COLORS.RED, end="")
status_text = ...
if status == 'RUN':
status_text = " RUN "
elif status == 'OK':
status_text = " OK "
elif status == 'PASSED':
status_text = " PASSED "
elif status == 'FAILED':
status_text = " FAILED "
else:
status_text = status
if status_text:
print("[{}]" . format(status_text), end="")
print(COLORS.ENDC, end="")
print(" {}" . format(message))
sys.stdout.flush()

View File

@ -4,47 +4,10 @@ import os
import pathlib
import shutil
import subprocess
import sys
import unittest
args = None
from .colored_print import (print_message, use_message_colors)
class COLORS_ANSI:
RED = '\033[00;31m'
GREEN = '\033[00;32m'
ENDC = '\033[0m'
class COLORS_DUMMY:
RED = ''
GREEN = ''
ENDC = ''
COLORS = COLORS_DUMMY
def print_message(message, type=None, status=''):
if type == 'SUCCESS':
print(COLORS.GREEN, end="")
elif type == 'FAILURE':
print(COLORS.RED, end="")
status_text = ...
if status == 'RUN':
status_text = " RUN "
elif status == 'OK':
status_text = " OK "
elif status == 'PASSED':
status_text = " PASSED "
elif status == 'FAILED':
status_text = " FAILED "
else:
status_text = status
if status_text:
print("[{}]" . format(status_text), end="")
print(COLORS.ENDC, end="")
print(" {}" . format(message))
sys.stdout.flush()
class AbstractImBufTest(unittest.TestCase):
deadpin marked this conversation as resolved

Can we deduplicate this colored printing code with other test modules?

Can we deduplicate this colored printing code with other test modules?
@classmethod
@ -65,8 +28,7 @@ class AbstractImBufTest(unittest.TestCase):
cls.verbose = os.environ.get("BLENDER_VERBOSE") is not None
cls.update = os.getenv('BLENDER_TEST_UPDATE') is not None
if os.environ.get("BLENDER_TEST_COLOR") is not None:
global COLORS, COLORS_ANSI
COLORS = COLORS_ANSI
use_message_colors()
def setUp(self):
self.errors = 0

View File

@ -14,44 +14,7 @@ import sys
import time
from . import global_report
class COLORS_ANSI:
RED = '\033[00;31m'
GREEN = '\033[00;32m'
ENDC = '\033[0m'
class COLORS_DUMMY:
RED = ''
GREEN = ''
ENDC = ''
COLORS = COLORS_DUMMY
def print_message(message, type=None, status=''):
if type == 'SUCCESS':
print(COLORS.GREEN, end="")
elif type == 'FAILURE':
print(COLORS.RED, end="")
status_text = ...
if status == 'RUN':
status_text = " RUN "
elif status == 'OK':
status_text = " OK "
elif status == 'PASSED':
status_text = " PASSED "
elif status == 'FAILED':
status_text = " FAILED "
else:
status_text = status
if status_text:
print("[{}]" . format(status_text), end="")
print(COLORS.ENDC, end="")
print(" {}" . format(message))
sys.stdout.flush()
from .colored_print import (print_message, use_message_colors)
def blend_list(dirpath, device, blacklist):
@ -151,8 +114,7 @@ class Report:
self.update = os.getenv('BLENDER_TEST_UPDATE') is not None
if os.environ.get("BLENDER_TEST_COLOR") is not None:
global COLORS, COLORS_ANSI
COLORS = COLORS_ANSI
use_message_colors()
self.failed_tests = ""
self.passed_tests = ""