Tests: Add tests for image format saving and loading #104442
|
@ -8,10 +8,9 @@ import unittest
|
|||
import bpy
|
||||
|
||||
sys.path.append(str(pathlib.Path(__file__).parent.absolute()))
|
||||
deadpin marked this conversation as resolved
|
||||
from modules.imbuf_test import (
|
||||
print_message,
|
||||
AbstractImBufTest
|
||||
)
|
||||
from modules.colored_print import print_message
|
||||
from modules.imbuf_test import AbstractImBufTest
|
||||
|
||||
|
||||
args = None
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
|
@ -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
Brecht Van Lommel
commented
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
|
||||
|
|
|
@ -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 = ""
|
||||
|
|
Loading…
Reference in New Issue
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.