Cleanup: pep8
This commit is contained in:
@@ -34,6 +34,7 @@ log = logging.getLogger("BlendFileReader")
|
|||||||
# module global routines
|
# module global routines
|
||||||
######################################################
|
######################################################
|
||||||
|
|
||||||
|
|
||||||
def ReadString(handle, length):
|
def ReadString(handle, length):
|
||||||
'''
|
'''
|
||||||
ReadString reads a String of given length or a zero terminating String
|
ReadString reads a String of given length or a zero terminating String
|
||||||
@@ -338,7 +339,7 @@ class DNAName:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def ShortName(self):
|
def ShortName(self):
|
||||||
result = self.Name;
|
result = self.Name
|
||||||
result = result.replace("*", "")
|
result = result.replace("*", "")
|
||||||
result = result.replace("(", "")
|
result = result.replace("(", "")
|
||||||
result = result.replace(")", "")
|
result = result.replace(")", "")
|
||||||
@@ -398,7 +399,7 @@ class DNAStructure:
|
|||||||
splitted = path.partition(".")
|
splitted = path.partition(".")
|
||||||
name = splitted[0]
|
name = splitted[0]
|
||||||
rest = splitted[2]
|
rest = splitted[2]
|
||||||
offset = 0;
|
offset = 0
|
||||||
for field in self.Fields:
|
for field in self.Fields:
|
||||||
if field.Name.ShortName() == name:
|
if field.Name.ShortName() == name:
|
||||||
log.debug("found " + name + "@" + str(offset))
|
log.debug("found " + name + "@" + str(offset))
|
||||||
@@ -443,4 +444,3 @@ class DNAField:
|
|||||||
return ReadString(handle, self.Name.ArraySize())
|
return ReadString(handle, self.Name.ArraySize())
|
||||||
else:
|
else:
|
||||||
return self.Type.Structure.GetField(header, handle, path)
|
return self.Type.Structure.GetField(header, handle, path)
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ def man_format(data):
|
|||||||
data = data.replace("\t", " ")
|
data = data.replace("\t", " ")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
import getopt
|
import getopt
|
||||||
raise getopt.GetoptError("Usage: %s <path-to-blender> <output-filename>" % sys.argv[0])
|
raise getopt.GetoptError("Usage: %s <path-to-blender> <output-filename>" % sys.argv[0])
|
||||||
|
@@ -73,6 +73,8 @@ def rna_info_BuildRNAInfo_cache():
|
|||||||
if rna_info_BuildRNAInfo_cache.ret is None:
|
if rna_info_BuildRNAInfo_cache.ret is None:
|
||||||
rna_info_BuildRNAInfo_cache.ret = rna_info.BuildRNAInfo()
|
rna_info_BuildRNAInfo_cache.ret = rna_info.BuildRNAInfo()
|
||||||
return rna_info_BuildRNAInfo_cache.ret
|
return rna_info_BuildRNAInfo_cache.ret
|
||||||
|
|
||||||
|
|
||||||
rna_info_BuildRNAInfo_cache.ret = None
|
rna_info_BuildRNAInfo_cache.ret = None
|
||||||
# --- end rna_info cache
|
# --- end rna_info cache
|
||||||
|
|
||||||
@@ -513,6 +515,8 @@ def escape_rst(text):
|
|||||||
""" Escape plain text which may contain characters used by RST.
|
""" Escape plain text which may contain characters used by RST.
|
||||||
"""
|
"""
|
||||||
return text.translate(escape_rst.trans)
|
return text.translate(escape_rst.trans)
|
||||||
|
|
||||||
|
|
||||||
escape_rst.trans = str.maketrans({
|
escape_rst.trans = str.maketrans({
|
||||||
"`": "\\`",
|
"`": "\\`",
|
||||||
"|": "\\|",
|
"|": "\\|",
|
||||||
@@ -1015,6 +1019,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
|||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
# Changes in Blender will force errors here
|
# Changes in Blender will force errors here
|
||||||
context_type_map = {
|
context_type_map = {
|
||||||
"active_base": ("ObjectBase", False),
|
"active_base": ("ObjectBase", False),
|
||||||
|
@@ -95,7 +95,9 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h,
|
|||||||
|
|
||||||
with open(filepath, 'wb') as f:
|
with open(filepath, 'wb') as f:
|
||||||
|
|
||||||
f.write(struct.pack('<6I',
|
f.write(
|
||||||
|
struct.pack(
|
||||||
|
'<6I',
|
||||||
sub_w, sub_h,
|
sub_w, sub_h,
|
||||||
sub_x, sub_y,
|
sub_x, sub_y,
|
||||||
# redundant but including to maintain consistency
|
# redundant but including to maintain consistency
|
||||||
@@ -113,7 +115,8 @@ def write_subimage(sub_x, sub_y, sub_w, sub_h,
|
|||||||
_dice_icon_name_cache = {}
|
_dice_icon_name_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def dice_icon_name(x, y, parts_x, parts_y,
|
def dice_icon_name(
|
||||||
|
x, y, parts_x, parts_y,
|
||||||
name_style=None, prefix=""):
|
name_style=None, prefix=""):
|
||||||
"""
|
"""
|
||||||
How to name icons, this is mainly for what name we get in git,
|
How to name icons, this is mainly for what name we get in git,
|
||||||
@@ -158,14 +161,16 @@ def dice_icon_name(x, y, parts_x, parts_y,
|
|||||||
return id_str
|
return id_str
|
||||||
|
|
||||||
|
|
||||||
def dice(filepath, output, output_prefix, name_style,
|
def dice(
|
||||||
|
filepath, output, output_prefix, name_style,
|
||||||
parts_x, parts_y,
|
parts_x, parts_y,
|
||||||
minx, miny, maxx, maxy,
|
minx, miny, maxx, maxy,
|
||||||
minx_icon, miny_icon, maxx_icon, maxy_icon,
|
minx_icon, miny_icon, maxx_icon, maxy_icon,
|
||||||
spacex_icon, spacey_icon,
|
spacex_icon, spacey_icon,
|
||||||
):
|
):
|
||||||
|
|
||||||
is_simple = (max(minx, miny, maxx, maxy,
|
is_simple = (max(
|
||||||
|
minx, miny, maxx, maxy,
|
||||||
minx_icon, miny_icon, maxx_icon, maxy_icon,
|
minx_icon, miny_icon, maxx_icon, maxy_icon,
|
||||||
spacex_icon, spacey_icon) == 0)
|
spacex_icon, spacey_icon) == 0)
|
||||||
|
|
||||||
@@ -199,9 +204,11 @@ def dice(filepath, output, output_prefix, name_style,
|
|||||||
|
|
||||||
for x in range(parts_x):
|
for x in range(parts_x):
|
||||||
for y in range(parts_y):
|
for y in range(parts_y):
|
||||||
id_str = dice_icon_name(x, y,
|
id_str = dice_icon_name(
|
||||||
|
x, y,
|
||||||
parts_x, parts_y,
|
parts_x, parts_y,
|
||||||
name_style=name_style, prefix=output_prefix)
|
name_style=name_style, prefix=output_prefix
|
||||||
|
)
|
||||||
filepath = os.path.join(output, id_str)
|
filepath = os.path.join(output, id_str)
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print(" writing:", filepath)
|
print(" writing:", filepath)
|
||||||
@@ -235,25 +242,35 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description=__doc__, epilog=epilog)
|
parser = argparse.ArgumentParser(description=__doc__, epilog=epilog)
|
||||||
|
|
||||||
# File path options
|
# File path options
|
||||||
parser.add_argument("--image", dest="image", metavar='FILE',
|
parser.add_argument(
|
||||||
help="Image file")
|
"--image", dest="image", metavar='FILE',
|
||||||
|
help="Image file",
|
||||||
parser.add_argument("--output", dest="output", metavar='DIR',
|
)
|
||||||
help="Output directory")
|
parser.add_argument(
|
||||||
|
"--output", dest="output", metavar='DIR',
|
||||||
parser.add_argument("--output_prefix", dest="output_prefix", metavar='STRING',
|
help="Output directory",
|
||||||
help="Output prefix")
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output_prefix", dest="output_prefix", metavar='STRING',
|
||||||
|
help="Output prefix",
|
||||||
|
)
|
||||||
|
|
||||||
# Icon naming option
|
# Icon naming option
|
||||||
parser.add_argument("--name_style", dest="name_style", metavar='ENUM', type=str,
|
parser.add_argument(
|
||||||
|
"--name_style", dest="name_style", metavar='ENUM', type=str,
|
||||||
choices=('', 'UI_ICONS'),
|
choices=('', 'UI_ICONS'),
|
||||||
help="The metod used for naming output data")
|
help="The metod used for naming output data",
|
||||||
|
)
|
||||||
|
|
||||||
# Options for dicing up the image
|
# Options for dicing up the image
|
||||||
parser.add_argument("--parts_x", dest="parts_x", metavar='INT', type=int,
|
parser.add_argument(
|
||||||
help="Grid X parts")
|
"--parts_x", dest="parts_x", metavar='INT', type=int,
|
||||||
parser.add_argument("--parts_y", dest="parts_y", metavar='INT', type=int,
|
help="Grid X parts",
|
||||||
help="Grid Y parts")
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--parts_y", dest="parts_y", metavar='INT', type=int,
|
||||||
|
help="Grid Y parts",
|
||||||
|
)
|
||||||
|
|
||||||
_help = "Inset from the outer edge (in pixels)"
|
_help = "Inset from the outer edge (in pixels)"
|
||||||
parser.add_argument("--minx", dest="minx", metavar='INT', type=int, help=_help)
|
parser.add_argument("--minx", dest="minx", metavar='INT', type=int, help=_help)
|
||||||
@@ -287,5 +304,6 @@ def main():
|
|||||||
args.spacex_icon, args.spacey_icon,
|
args.spacex_icon, args.spacey_icon,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -67,5 +67,6 @@ def main():
|
|||||||
|
|
||||||
icondata_to_png(file_src, file_dst)
|
icondata_to_png(file_src, file_dst)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -94,8 +94,10 @@ def check_prefix(prop, btype):
|
|||||||
|
|
||||||
|
|
||||||
def check_if_changed(a, b):
|
def check_if_changed(a, b):
|
||||||
if a != b: return 'changed'
|
if a != b:
|
||||||
else: return 'same'
|
return 'changed'
|
||||||
|
else:
|
||||||
|
return 'same'
|
||||||
|
|
||||||
|
|
||||||
def get_props_from_txt(input_filename):
|
def get_props_from_txt(input_filename):
|
||||||
@@ -262,14 +264,19 @@ def write_files(basename, props_list, props_length_max):
|
|||||||
# txt
|
# txt
|
||||||
|
|
||||||
# quick way we can tell if it changed
|
# quick way we can tell if it changed
|
||||||
if props[3] == props[4]: txt += "#"
|
if props[3] == props[4]:
|
||||||
else: txt += " "
|
txt += "#"
|
||||||
|
else:
|
||||||
|
txt += " "
|
||||||
|
|
||||||
if props[0] != '': txt += '%s * ' % props[0] # comment
|
if props[0] != '':
|
||||||
|
txt += '%s * ' % props[0] # comment
|
||||||
txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
|
txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
|
||||||
# rna_api
|
# rna_api
|
||||||
if props[0] == 'NOTE': indent = '# '
|
if props[0] == 'NOTE':
|
||||||
else: indent = ' '
|
indent = '# '
|
||||||
|
else:
|
||||||
|
indent = ' '
|
||||||
rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
|
rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
|
||||||
# py
|
# py
|
||||||
blanks = [' ' * (x[0] - x[1]) for x in zip(props_length_max, list(map(len, props)))]
|
blanks = [' ' * (x[0] - x[1]) for x in zip(props_length_max, list(map(len, props)))]
|
||||||
@@ -300,7 +307,7 @@ def main():
|
|||||||
|
|
||||||
sort_choices = ['note', 'changed', 'class', 'from', 'to', 'kw', 'class.to']
|
sort_choices = ['note', 'changed', 'class', 'from', 'to', 'kw', 'class.to']
|
||||||
default_sort_choice = sort_choices[-1]
|
default_sort_choice = sort_choices[-1]
|
||||||
kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \
|
kw_prefixes = ['active', 'apply', 'bl', 'exclude', 'has', 'invert', 'is', 'lock',
|
||||||
'pressed', 'show', 'show_only', 'use', 'use_only', 'layers', 'states', 'select']
|
'pressed', 'show', 'show_only', 'use', 'use_only', 'layers', 'states', 'select']
|
||||||
kw = ['active', 'hide', 'invert', 'select', 'layers', 'mute', 'states', 'use', 'lock']
|
kw = ['active', 'hide', 'invert', 'select', 'layers', 'mute', 'states', 'use', 'lock']
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import sys
|
|||||||
Example usage:
|
Example usage:
|
||||||
python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py
|
python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
def work_line_id(line):
|
def work_line_id(line):
|
||||||
return line[2].split("|")[-1], line[3] # class/from
|
return line[2].split("|")[-1], line[3] # class/from
|
||||||
|
|
||||||
|
|
||||||
if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
|
if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
|
||||||
print("Only accepts 2 py files as arguments.")
|
print("Only accepts 2 py files as arguments.")
|
||||||
|
|
||||||
@@ -57,5 +58,6 @@ def main():
|
|||||||
write_work_file(file_path, list(mod_from_dict.values()))
|
write_work_file(file_path, list(mod_from_dict.values()))
|
||||||
print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__))
|
print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -129,6 +129,7 @@ def seek(r, txt, recurs):
|
|||||||
newtxt = txt + '[' + str(i) + ']'
|
newtxt = txt + '[' + str(i) + ']'
|
||||||
seek(r[i], newtxt, recurs + 1)
|
seek(r[i], newtxt, recurs + 1)
|
||||||
|
|
||||||
|
|
||||||
seek(bpy.data, 'bpy.data', 0)
|
seek(bpy.data, 'bpy.data', 0)
|
||||||
# seek(bpy.types, 'bpy.types', 0)
|
# seek(bpy.types, 'bpy.types', 0)
|
||||||
'''
|
'''
|
||||||
|
@@ -50,8 +50,10 @@ for d in defs.split('\n'):
|
|||||||
if not w:
|
if not w:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try: w.remove("#define")
|
try:
|
||||||
except: pass
|
w.remove("#define")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# print w
|
# print w
|
||||||
|
|
||||||
|
@@ -142,5 +142,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print("\nnone found!")
|
print("\nnone found!")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@@ -33,7 +33,6 @@ from modules.test_utils import (with_tempdir,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AbcPropError(Exception):
|
class AbcPropError(Exception):
|
||||||
"""Raised when AbstractAlembicTest.abcprop() finds an error."""
|
"""Raised when AbstractAlembicTest.abcprop() finds an error."""
|
||||||
|
|
||||||
|
@@ -107,7 +107,6 @@ class SimpleImportTest(AbstractAlembicTest):
|
|||||||
self.assertAlmostEqual(0, y)
|
self.assertAlmostEqual(0, y)
|
||||||
self.assertAlmostEqual(2, z)
|
self.assertAlmostEqual(2, z)
|
||||||
|
|
||||||
|
|
||||||
def test_select_after_import(self):
|
def test_select_after_import(self):
|
||||||
# Add a sphere, so that there is something in the scene, selected, and active,
|
# Add a sphere, so that there is something in the scene, selected, and active,
|
||||||
# before we do the Alembic import.
|
# before we do the Alembic import.
|
||||||
|
@@ -56,7 +56,8 @@ def addon_modules_sorted():
|
|||||||
modules[:] = [
|
modules[:] = [
|
||||||
mod for mod in modules
|
mod for mod in modules
|
||||||
if not (mod.__file__.startswith(BLACKLIST_DIRS))
|
if not (mod.__file__.startswith(BLACKLIST_DIRS))
|
||||||
if not (mod.__name__ in BLACKLIST_ADDONS)]
|
if not (mod.__name__ in BLACKLIST_ADDONS)
|
||||||
|
]
|
||||||
modules.sort(key=lambda mod: mod.__name__)
|
modules.sort(key=lambda mod: mod.__name__)
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
|
@@ -248,6 +248,7 @@ def main():
|
|||||||
load_addons()
|
load_addons()
|
||||||
load_modules()
|
load_modules()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# So a python error exits(1)
|
# So a python error exits(1)
|
||||||
try:
|
try:
|
||||||
|
@@ -61,11 +61,11 @@ def render_gl(context, filepath, shade):
|
|||||||
|
|
||||||
ctx_viewport_shade(context, shade)
|
ctx_viewport_shade(context, shade)
|
||||||
|
|
||||||
#~ # stop to inspect!
|
# stop to inspect!
|
||||||
#~ if filepath == "test_cube_shell_solidify_subsurf_wp_wire":
|
# if filepath == "test_cube_shell_solidify_subsurf_wp_wire":
|
||||||
#~ assert(0)
|
# assert(0)
|
||||||
#~ else:
|
# else:
|
||||||
#~ return
|
# return
|
||||||
|
|
||||||
bpy.ops.render.opengl(write_still=True,
|
bpy.ops.render.opengl(write_still=True,
|
||||||
view_context=True)
|
view_context=True)
|
||||||
@@ -219,6 +219,7 @@ def mesh_bmesh_poly_elems(poly, elems):
|
|||||||
vert_total = poly.loop_total
|
vert_total = poly.loop_total
|
||||||
return elems[vert_start:vert_start + vert_total]
|
return elems[vert_start:vert_start + vert_total]
|
||||||
|
|
||||||
|
|
||||||
def mesh_bmesh_poly_vertices(poly):
|
def mesh_bmesh_poly_vertices(poly):
|
||||||
return [loop.vertex_index
|
return [loop.vertex_index
|
||||||
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
||||||
@@ -678,55 +679,73 @@ def make_monkey_extra(scene):
|
|||||||
|
|
||||||
global_tests = []
|
global_tests = []
|
||||||
|
|
||||||
global_tests.append(("none",
|
global_tests.append(
|
||||||
|
("none",
|
||||||
(),
|
(),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
# single
|
# single
|
||||||
global_tests.append(("subsurf_single",
|
global_tests.append(
|
||||||
|
("subsurf_single",
|
||||||
((modifier_subsurf_add, dict(levels=2)), ),
|
((modifier_subsurf_add, dict(levels=2)), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
global_tests.append(
|
||||||
global_tests.append(("armature_single",
|
("armature_single",
|
||||||
((modifier_armature_add, dict()), ),
|
((modifier_armature_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
global_tests.append(
|
||||||
global_tests.append(("mirror_single",
|
("mirror_single",
|
||||||
((modifier_mirror_add, dict()), ),
|
((modifier_mirror_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
global_tests.append(("hook_single",
|
global_tests.append(
|
||||||
|
("hook_single",
|
||||||
((modifier_hook_add, dict()), ),
|
((modifier_hook_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
global_tests.append(("decimate_single",
|
global_tests.append(
|
||||||
|
("decimate_single",
|
||||||
((modifier_decimate_add, dict()), ),
|
((modifier_decimate_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
global_tests.append(("build_single",
|
global_tests.append(
|
||||||
|
("build_single",
|
||||||
((modifier_build_add, dict()), ),
|
((modifier_build_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
global_tests.append(("mask_single",
|
global_tests.append(
|
||||||
|
("mask_single",
|
||||||
((modifier_mask_add, dict()), ),
|
((modifier_mask_add, dict()), ),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# combinations
|
# combinations
|
||||||
global_tests.append(("mirror_subsurf",
|
global_tests.append(
|
||||||
|
("mirror_subsurf",
|
||||||
((modifier_mirror_add, dict()),
|
((modifier_mirror_add, dict()),
|
||||||
(modifier_subsurf_add, dict(levels=2))),
|
(modifier_subsurf_add, dict(levels=2))),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
global_tests.append(("solidify_subsurf",
|
global_tests.append(
|
||||||
|
("solidify_subsurf",
|
||||||
((modifier_solidify_add, dict()),
|
((modifier_solidify_add, dict()),
|
||||||
(modifier_subsurf_add, dict(levels=2))),
|
(modifier_subsurf_add, dict(levels=2))),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def apply_test(test, scene, obj,
|
def apply_test(
|
||||||
|
test, scene, obj,
|
||||||
render_func=None,
|
render_func=None,
|
||||||
render_args=None,
|
render_args=None,
|
||||||
render_kwargs=None,
|
render_kwargs=None,
|
||||||
@@ -756,10 +775,12 @@ def test_cube(context, test):
|
|||||||
obj = make_cube_extra(scene)
|
obj = make_cube_extra(scene)
|
||||||
ctx_camera_setup(context, location=(3, 3, 3))
|
ctx_camera_setup(context, location=(3, 3, 3))
|
||||||
|
|
||||||
apply_test(test, scene, obj,
|
apply_test(
|
||||||
|
test, scene, obj,
|
||||||
render_func=render_gl_all_modes,
|
render_func=render_gl_all_modes,
|
||||||
render_args=(context, obj),
|
render_args=(context, obj),
|
||||||
render_kwargs=dict(filepath=whoami()))
|
render_kwargs=dict(filepath=whoami())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cube_like(context, test):
|
def test_cube_like(context, test):
|
||||||
@@ -767,10 +788,12 @@ def test_cube_like(context, test):
|
|||||||
obj = make_cube_like_extra(scene)
|
obj = make_cube_like_extra(scene)
|
||||||
ctx_camera_setup(context, location=(5, 5, 5))
|
ctx_camera_setup(context, location=(5, 5, 5))
|
||||||
|
|
||||||
apply_test(test, scene, obj,
|
apply_test(
|
||||||
|
test, scene, obj,
|
||||||
render_func=render_gl_all_modes,
|
render_func=render_gl_all_modes,
|
||||||
render_args=(context, obj),
|
render_args=(context, obj),
|
||||||
render_kwargs=dict(filepath=whoami()))
|
render_kwargs=dict(filepath=whoami())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cube_shell(context, test):
|
def test_cube_shell(context, test):
|
||||||
@@ -778,10 +801,12 @@ def test_cube_shell(context, test):
|
|||||||
obj = make_cube_shell_extra(scene)
|
obj = make_cube_shell_extra(scene)
|
||||||
ctx_camera_setup(context, location=(4, 4, 4))
|
ctx_camera_setup(context, location=(4, 4, 4))
|
||||||
|
|
||||||
apply_test(test, scene, obj,
|
apply_test(
|
||||||
|
test, scene, obj,
|
||||||
render_func=render_gl_all_modes,
|
render_func=render_gl_all_modes,
|
||||||
render_args=(context, obj),
|
render_args=(context, obj),
|
||||||
render_kwargs=dict(filepath=whoami()))
|
render_kwargs=dict(filepath=whoami())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@@ -5,11 +5,12 @@ import unittest
|
|||||||
|
|
||||||
from bpy.utils import units
|
from bpy.utils import units
|
||||||
|
|
||||||
|
|
||||||
class UnitsTesting(unittest.TestCase):
|
class UnitsTesting(unittest.TestCase):
|
||||||
# From user typing to 'internal' Blender value.
|
# From user typing to 'internal' Blender value.
|
||||||
INPUT_TESTS = (
|
INPUT_TESTS = (
|
||||||
# system, type, ref, input, value
|
# system, type, ref, input, value
|
||||||
##### LENGTH
|
# LENGTH
|
||||||
('IMPERIAL', 'LENGTH', "", "1ft", 0.3048),
|
('IMPERIAL', 'LENGTH', "", "1ft", 0.3048),
|
||||||
('IMPERIAL', 'LENGTH', "", "(1+1)ft", 0.3048 * 2),
|
('IMPERIAL', 'LENGTH', "", "(1+1)ft", 0.3048 * 2),
|
||||||
('IMPERIAL', 'LENGTH', "", "1mi4\"", 1609.344 + 0.0254 * 4),
|
('IMPERIAL', 'LENGTH', "", "1mi4\"", 1609.344 + 0.0254 * 4),
|
||||||
@@ -31,7 +32,7 @@ class UnitsTesting(unittest.TestCase):
|
|||||||
# From 'internal' Blender value to user-friendly printing
|
# From 'internal' Blender value to user-friendly printing
|
||||||
OUTPUT_TESTS = (
|
OUTPUT_TESTS = (
|
||||||
# system, type, prec, sep, compat, value, output
|
# system, type, prec, sep, compat, value, output
|
||||||
##### LENGTH
|
# LENGTH
|
||||||
# Note: precision handling is a bit complicated when using multi-units...
|
# Note: precision handling is a bit complicated when using multi-units...
|
||||||
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
|
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
|
||||||
('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
|
('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
|
||||||
@@ -63,9 +64,13 @@ class UnitsTesting(unittest.TestCase):
|
|||||||
def test_units_outputs(self):
|
def test_units_outputs(self):
|
||||||
for usys, utype, prec, sep, compat, val, output in self.OUTPUT_TESTS:
|
for usys, utype, prec, sep, compat, val, output in self.OUTPUT_TESTS:
|
||||||
opt_str = units.to_string(usys, utype, val, prec, sep, compat)
|
opt_str = units.to_string(usys, utype, val, prec, sep, compat)
|
||||||
self.assertEqual(opt_str, output,
|
self.assertEqual(
|
||||||
msg="%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => "
|
opt_str, output,
|
||||||
"\"%s\", expected \"%s\"" % (usys, utype, val, prec, sep, compat, opt_str, output))
|
msg=(
|
||||||
|
"%s, %s: %f (precision: %d, separate units: %d, compat units: %d) => "
|
||||||
|
"\"%s\", expected \"%s\""
|
||||||
|
) % (usys, utype, val, prec, sep, compat, opt_str, output)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@@ -198,6 +198,7 @@ class TestBufferProtocol(TestHelper, unittest.TestCase):
|
|||||||
self.assertEqual(list(view1), list(view2))
|
self.assertEqual(list(view1), list(view2))
|
||||||
self.assertEqual(view1.tobytes(), view2.tobytes())
|
self.assertEqual(view1.tobytes(), view2.tobytes())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
||||||
|
@@ -61,8 +61,10 @@ class TestClass(bpy.types.PropertyGroup):
|
|||||||
def get_scene(lib_name, sce_name):
|
def get_scene(lib_name, sce_name):
|
||||||
for s in bpy.data.scenes:
|
for s in bpy.data.scenes:
|
||||||
if s.name == sce_name:
|
if s.name == sce_name:
|
||||||
if (s.library and s.library.name == lib_name) or \
|
if (
|
||||||
(lib_name == None and s.library == None):
|
(s.library and s.library.name == lib_name) or
|
||||||
|
(lib_name is None and s.library is None)
|
||||||
|
):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
@@ -309,6 +311,7 @@ def test_restrictions2():
|
|||||||
|
|
||||||
class TestUIList(UIList):
|
class TestUIList(UIList):
|
||||||
test = bpy.props.PointerProperty(type=bpy.types.Object)
|
test = bpy.props.PointerProperty(type=bpy.types.Object)
|
||||||
|
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||||
layout.prop(item, "name", text="", emboss=False, icon_value=icon)
|
layout.prop(item, "name", text="", emboss=False, icon_value=icon)
|
||||||
|
|
||||||
|
@@ -372,7 +372,6 @@ class KDTreeTesting(unittest.TestCase):
|
|||||||
ret_filter = k_all.find(co, lambda i: (i % 2) == 0)
|
ret_filter = k_all.find(co, lambda i: (i % 2) == 0)
|
||||||
self.assertAlmostEqualVector(ret_regular, ret_filter)
|
self.assertAlmostEqualVector(ret_regular, ret_filter)
|
||||||
|
|
||||||
|
|
||||||
# filter out all values (search odd tree for even values and the reverse)
|
# filter out all values (search odd tree for even values and the reverse)
|
||||||
co = (0,) * 3
|
co = (0,) * 3
|
||||||
ret_filter = k_odd.find(co, lambda i: (i % 2) == 0)
|
ret_filter = k_odd.find(co, lambda i: (i % 2) == 0)
|
||||||
|
@@ -142,5 +142,6 @@ def main():
|
|||||||
|
|
||||||
print("Error (total): %d" % GLOBALS["error_num"])
|
print("Error (total): %d" % GLOBALS["error_num"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -155,5 +155,6 @@ def main():
|
|||||||
test_language_coverage()
|
test_language_coverage()
|
||||||
test_urls()
|
test_urls()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -114,6 +114,7 @@ def blend_list(mainpath):
|
|||||||
|
|
||||||
return list(sorted(file_list(mainpath, is_blend)))
|
return list(sorted(file_list(mainpath, is_blend)))
|
||||||
|
|
||||||
|
|
||||||
if USE_FILES:
|
if USE_FILES:
|
||||||
USE_FILES_LS = blend_list(USE_FILES)
|
USE_FILES_LS = blend_list(USE_FILES)
|
||||||
# print(USE_FILES_LS)
|
# print(USE_FILES_LS)
|
||||||
@@ -480,6 +481,7 @@ def main():
|
|||||||
|
|
||||||
print("Finished %r" % __file__)
|
print("Finished %r" % __file__)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# ~ for i in range(200):
|
# ~ for i in range(200):
|
||||||
# ~ RANDOM_SEED[0] += 1
|
# ~ RANDOM_SEED[0] += 1
|
||||||
|
@@ -31,6 +31,7 @@ import difflib
|
|||||||
import pathlib
|
import pathlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def with_tempdir(wrapped):
|
def with_tempdir(wrapped):
|
||||||
"""Creates a temporary directory for the function, cleaning up after it returns normally.
|
"""Creates a temporary directory for the function, cleaning up after it returns normally.
|
||||||
|
|
||||||
@@ -56,8 +57,10 @@ def with_tempdir(wrapped):
|
|||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
LINE = "+----------------------------------------------------------------"
|
LINE = "+----------------------------------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
class AbstractColladaTest(unittest.TestCase):
|
class AbstractColladaTest(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -75,7 +78,7 @@ class AbstractColladaTest(unittest.TestCase):
|
|||||||
ref.close()
|
ref.close()
|
||||||
exp.close()
|
exp.close()
|
||||||
|
|
||||||
diff_count = 0;
|
diff_count = 0
|
||||||
for line in diff:
|
for line in diff:
|
||||||
error = True
|
error = True
|
||||||
for prefix in ('---', '+++', '@@'):
|
for prefix in ('---', '+++', '@@'):
|
||||||
@@ -107,6 +110,7 @@ class AbstractColladaTest(unittest.TestCase):
|
|||||||
|
|
||||||
return diff_count == 0
|
return diff_count == 0
|
||||||
|
|
||||||
|
|
||||||
class MeshExportTest4(AbstractColladaTest):
|
class MeshExportTest4(AbstractColladaTest):
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_export_animation_suzannes_sample_matrix(self, tempdir: pathlib.Path):
|
def test_export_animation_suzannes_sample_matrix(self, tempdir: pathlib.Path):
|
||||||
@@ -114,7 +118,8 @@ class MeshExportTest4(AbstractColladaTest):
|
|||||||
reference_dae = self.testdir / Path("%s.dae" % test)
|
reference_dae = self.testdir / Path("%s.dae" % test)
|
||||||
outfile = tempdir / Path("%s_out.dae" % test)
|
outfile = tempdir / Path("%s_out.dae" % test)
|
||||||
|
|
||||||
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
|
bpy.ops.wm.collada_export(
|
||||||
|
filepath="%s" % str(outfile),
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
filemode=8,
|
filemode=8,
|
||||||
display_type='DEFAULT',
|
display_type='DEFAULT',
|
||||||
@@ -142,12 +147,14 @@ class MeshExportTest4(AbstractColladaTest):
|
|||||||
export_texture_type_selection='mat',
|
export_texture_type_selection='mat',
|
||||||
open_sim=False,
|
open_sim=False,
|
||||||
limit_precision=True,
|
limit_precision=True,
|
||||||
keep_bind_info=False)
|
keep_bind_info=False,
|
||||||
|
)
|
||||||
|
|
||||||
# Now check the resulting Collada file.
|
# Now check the resulting Collada file.
|
||||||
if not self.checkdae(reference_dae, outfile):
|
if not self.checkdae(reference_dae, outfile):
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
class MeshExportTest3(AbstractColladaTest):
|
class MeshExportTest3(AbstractColladaTest):
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_export_animation_suzannes_sample_locrotscale(self, tempdir: pathlib.Path):
|
def test_export_animation_suzannes_sample_locrotscale(self, tempdir: pathlib.Path):
|
||||||
@@ -155,7 +162,8 @@ class MeshExportTest3(AbstractColladaTest):
|
|||||||
reference_dae = self.testdir / Path("%s.dae" % test)
|
reference_dae = self.testdir / Path("%s.dae" % test)
|
||||||
outfile = tempdir / Path("%s_out.dae" % test)
|
outfile = tempdir / Path("%s_out.dae" % test)
|
||||||
|
|
||||||
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
|
bpy.ops.wm.collada_export(
|
||||||
|
filepath="%s" % str(outfile),
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
filemode=8,
|
filemode=8,
|
||||||
display_type='DEFAULT',
|
display_type='DEFAULT',
|
||||||
@@ -183,12 +191,14 @@ class MeshExportTest3(AbstractColladaTest):
|
|||||||
export_texture_type_selection='mat',
|
export_texture_type_selection='mat',
|
||||||
open_sim=False,
|
open_sim=False,
|
||||||
limit_precision=True,
|
limit_precision=True,
|
||||||
keep_bind_info=False)
|
keep_bind_info=False,
|
||||||
|
)
|
||||||
|
|
||||||
# Now check the resulting Collada file.
|
# Now check the resulting Collada file.
|
||||||
if not self.checkdae(reference_dae, outfile):
|
if not self.checkdae(reference_dae, outfile):
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
class MeshExportTest2(AbstractColladaTest):
|
class MeshExportTest2(AbstractColladaTest):
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_export_animation_suzannes_keyframe_matrix(self, tempdir: pathlib.Path):
|
def test_export_animation_suzannes_keyframe_matrix(self, tempdir: pathlib.Path):
|
||||||
@@ -196,7 +206,8 @@ class MeshExportTest2(AbstractColladaTest):
|
|||||||
reference_dae = self.testdir / Path("%s.dae" % test)
|
reference_dae = self.testdir / Path("%s.dae" % test)
|
||||||
outfile = tempdir / Path("%s_out.dae" % test)
|
outfile = tempdir / Path("%s_out.dae" % test)
|
||||||
|
|
||||||
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
|
bpy.ops.wm.collada_export(
|
||||||
|
filepath="%s" % str(outfile),
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
filemode=8,
|
filemode=8,
|
||||||
display_type='DEFAULT',
|
display_type='DEFAULT',
|
||||||
@@ -224,12 +235,14 @@ class MeshExportTest2(AbstractColladaTest):
|
|||||||
export_texture_type_selection='mat',
|
export_texture_type_selection='mat',
|
||||||
open_sim=False,
|
open_sim=False,
|
||||||
limit_precision=True,
|
limit_precision=True,
|
||||||
keep_bind_info=False)
|
keep_bind_info=False,
|
||||||
|
)
|
||||||
|
|
||||||
# Now check the resulting Collada file.
|
# Now check the resulting Collada file.
|
||||||
if not self.checkdae(reference_dae, outfile):
|
if not self.checkdae(reference_dae, outfile):
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
class MeshExportTest1(AbstractColladaTest):
|
class MeshExportTest1(AbstractColladaTest):
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_export_animation_suzannes_keyframe_locrotscale(self, tempdir: pathlib.Path):
|
def test_export_animation_suzannes_keyframe_locrotscale(self, tempdir: pathlib.Path):
|
||||||
@@ -237,7 +250,8 @@ class MeshExportTest1(AbstractColladaTest):
|
|||||||
reference_dae = self.testdir / Path("%s.dae" % test)
|
reference_dae = self.testdir / Path("%s.dae" % test)
|
||||||
outfile = tempdir / Path("%s_out.dae" % test)
|
outfile = tempdir / Path("%s_out.dae" % test)
|
||||||
|
|
||||||
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
|
bpy.ops.wm.collada_export(
|
||||||
|
filepath="%s" % str(outfile),
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
filemode=8,
|
filemode=8,
|
||||||
display_type='DEFAULT',
|
display_type='DEFAULT',
|
||||||
@@ -265,7 +279,8 @@ class MeshExportTest1(AbstractColladaTest):
|
|||||||
export_texture_type_selection='mat',
|
export_texture_type_selection='mat',
|
||||||
open_sim=False,
|
open_sim=False,
|
||||||
limit_precision=True,
|
limit_precision=True,
|
||||||
keep_bind_info=False)
|
keep_bind_info=False,
|
||||||
|
)
|
||||||
|
|
||||||
# Now check the resulting Collada file.
|
# Now check the resulting Collada file.
|
||||||
if not self.checkdae(reference_dae, outfile):
|
if not self.checkdae(reference_dae, outfile):
|
||||||
|
@@ -31,6 +31,7 @@ import difflib
|
|||||||
import pathlib
|
import pathlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def with_tempdir(wrapped):
|
def with_tempdir(wrapped):
|
||||||
"""Creates a temporary directory for the function, cleaning up after it returns normally.
|
"""Creates a temporary directory for the function, cleaning up after it returns normally.
|
||||||
|
|
||||||
@@ -56,8 +57,10 @@ def with_tempdir(wrapped):
|
|||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
LINE = "+----------------------------------------------------------------"
|
LINE = "+----------------------------------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
class AbstractColladaTest(unittest.TestCase):
|
class AbstractColladaTest(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -75,7 +78,7 @@ class AbstractColladaTest(unittest.TestCase):
|
|||||||
ref.close()
|
ref.close()
|
||||||
exp.close()
|
exp.close()
|
||||||
|
|
||||||
diff_count = 0;
|
diff_count = 0
|
||||||
for line in diff:
|
for line in diff:
|
||||||
error = True
|
error = True
|
||||||
for prefix in ('---', '+++', '@@'):
|
for prefix in ('---', '+++', '@@'):
|
||||||
@@ -107,6 +110,7 @@ class AbstractColladaTest(unittest.TestCase):
|
|||||||
|
|
||||||
return diff_count == 0
|
return diff_count == 0
|
||||||
|
|
||||||
|
|
||||||
class MeshExportTest(AbstractColladaTest):
|
class MeshExportTest(AbstractColladaTest):
|
||||||
@with_tempdir
|
@with_tempdir
|
||||||
def test_export_single_mesh(self, tempdir: pathlib.Path):
|
def test_export_single_mesh(self, tempdir: pathlib.Path):
|
||||||
@@ -114,7 +118,8 @@ class MeshExportTest(AbstractColladaTest):
|
|||||||
reference_dae = self.testdir / Path("%s.dae" % test)
|
reference_dae = self.testdir / Path("%s.dae" % test)
|
||||||
outfile = tempdir / Path("%s_out.dae" % test)
|
outfile = tempdir / Path("%s_out.dae" % test)
|
||||||
|
|
||||||
bpy.ops.wm.collada_export(filepath="%s" % str(outfile),
|
bpy.ops.wm.collada_export(
|
||||||
|
filepath="%s" % str(outfile),
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
filemode=8,
|
filemode=8,
|
||||||
display_type="DEFAULT",
|
display_type="DEFAULT",
|
||||||
@@ -140,12 +145,14 @@ class MeshExportTest(AbstractColladaTest):
|
|||||||
export_texture_type_selection="mat",
|
export_texture_type_selection="mat",
|
||||||
open_sim=False,
|
open_sim=False,
|
||||||
limit_precision=False,
|
limit_precision=False,
|
||||||
keep_bind_info=False)
|
keep_bind_info=False,
|
||||||
|
)
|
||||||
|
|
||||||
# Now check the resulting Collada file.
|
# Now check the resulting Collada file.
|
||||||
if not self.checkdae(reference_dae, outfile):
|
if not self.checkdae(reference_dae, outfile):
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@@ -23,6 +23,7 @@ class COLORS_DUMMY:
|
|||||||
GREEN = ''
|
GREEN = ''
|
||||||
ENDC = ''
|
ENDC = ''
|
||||||
|
|
||||||
|
|
||||||
COLORS = COLORS_DUMMY
|
COLORS = COLORS_DUMMY
|
||||||
|
|
||||||
|
|
||||||
@@ -55,10 +56,12 @@ def blend_list(dirpath):
|
|||||||
filepath = os.path.join(dirpath, filename)
|
filepath = os.path.join(dirpath, filename)
|
||||||
yield filepath
|
yield filepath
|
||||||
|
|
||||||
|
|
||||||
def test_get_name(filepath):
|
def test_get_name(filepath):
|
||||||
filename = os.path.basename(filepath)
|
filename = os.path.basename(filepath)
|
||||||
return os.path.splitext(filename)[0]
|
return os.path.splitext(filename)[0]
|
||||||
|
|
||||||
|
|
||||||
def test_get_images(output_dir, filepath):
|
def test_get_images(output_dir, filepath):
|
||||||
testname = test_get_name(filepath)
|
testname = test_get_name(filepath)
|
||||||
dirpath = os.path.dirname(filepath)
|
dirpath = os.path.dirname(filepath)
|
||||||
@@ -257,7 +260,6 @@ class Report:
|
|||||||
else:
|
else:
|
||||||
self.passed_tests += test_html
|
self.passed_tests += test_html
|
||||||
|
|
||||||
|
|
||||||
def _diff_output(self, filepath, tmp_filepath):
|
def _diff_output(self, filepath, tmp_filepath):
|
||||||
old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath)
|
old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath)
|
||||||
|
|
||||||
@@ -317,7 +319,6 @@ class Report:
|
|||||||
|
|
||||||
return not failed
|
return not failed
|
||||||
|
|
||||||
|
|
||||||
def _run_test(self, filepath, render_cb):
|
def _run_test(self, filepath, render_cb):
|
||||||
testname = test_get_name(filepath)
|
testname = test_get_name(filepath)
|
||||||
print_message(testname, 'SUCCESS', 'RUN')
|
print_message(testname, 'SUCCESS', 'RUN')
|
||||||
@@ -354,7 +355,6 @@ class Report:
|
|||||||
'FAILURE', 'FAILED')
|
'FAILURE', 'FAILED')
|
||||||
return error
|
return error
|
||||||
|
|
||||||
|
|
||||||
def _run_all_tests(self, dirname, dirpath, render_cb):
|
def _run_all_tests(self, dirname, dirpath, render_cb):
|
||||||
passed_tests = []
|
passed_tests = []
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
|
@@ -62,7 +62,6 @@ class AbstractBlenderRunnerTest(unittest.TestCase):
|
|||||||
blender: pathlib.Path = None
|
blender: pathlib.Path = None
|
||||||
testdir: pathlib.Path = None
|
testdir: pathlib.Path = None
|
||||||
|
|
||||||
|
|
||||||
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
|
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
|
||||||
"""Runs Blender by opening a blendfile and executing a script.
|
"""Runs Blender by opening a blendfile and executing a script.
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def screenshot():
|
def screenshot():
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ def screenshot():
|
|||||||
|
|
||||||
bpy.ops.wm.quit_blender()
|
bpy.ops.wm.quit_blender()
|
||||||
|
|
||||||
|
|
||||||
# When run from inside Blender, take screenshot and exit.
|
# When run from inside Blender, take screenshot and exit.
|
||||||
try:
|
try:
|
||||||
import bpy
|
import bpy
|
||||||
@@ -93,5 +95,6 @@ def main():
|
|||||||
|
|
||||||
sys.exit(not ok)
|
sys.exit(not ok)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -204,6 +204,5 @@ def main():
|
|||||||
print("Skipping pylint checks (command not found)")
|
print("Skipping pylint checks (command not found)")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -12,6 +12,7 @@ test= bpy.data.test
|
|||||||
|
|
||||||
# same as above for other types except that the first letter is "i" for int and "b" for bool
|
# same as above for other types except that the first letter is "i" for int and "b" for bool
|
||||||
|
|
||||||
|
|
||||||
class TestArray(unittest.TestCase):
|
class TestArray(unittest.TestCase):
|
||||||
# test that assignment works by: assign -> test value
|
# test that assignment works by: assign -> test value
|
||||||
# - rvalue = list of float
|
# - rvalue = list of float
|
||||||
@@ -181,7 +182,6 @@ class TestMArray(unittest.TestCase):
|
|||||||
arr[i][j] = rval
|
arr[i][j] = rval
|
||||||
self.assertEqual(prop_to_list(arr[i][j]), rval)
|
self.assertEqual(prop_to_list(arr[i][j]), rval)
|
||||||
|
|
||||||
|
|
||||||
def test_assign_item_fail(self):
|
def test_assign_item_fail(self):
|
||||||
def assign_wrong_size(arr, i, rval):
|
def assign_wrong_size(arr, i, rval):
|
||||||
getattr(test, arr)[i] = rval
|
getattr(test, arr)[i] = rval
|
||||||
@@ -212,8 +212,8 @@ class TestMArray(unittest.TestCase):
|
|||||||
setattr(test, arr, rval)
|
setattr(test, arr, rval)
|
||||||
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
|
self.assertEqual(prop_to_list(getattr(test, arr)), rval)
|
||||||
|
|
||||||
|
|
||||||
# test access
|
# test access
|
||||||
|
|
||||||
def test_access(self):
|
def test_access(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -221,17 +221,22 @@ class TestMArray(unittest.TestCase):
|
|||||||
def test_access_fail(self):
|
def test_access_fail(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
random.seed()
|
random.seed()
|
||||||
|
|
||||||
|
|
||||||
def rand_int():
|
def rand_int():
|
||||||
return random.randint(-1000, 1000)
|
return random.randint(-1000, 1000)
|
||||||
|
|
||||||
|
|
||||||
def rand_float():
|
def rand_float():
|
||||||
return float(rand_int())
|
return float(rand_int())
|
||||||
|
|
||||||
|
|
||||||
def rand_bool():
|
def rand_bool():
|
||||||
return bool(random.randint(0, 1))
|
return bool(random.randint(0, 1))
|
||||||
|
|
||||||
|
|
||||||
def make_random_array(len, rand_func):
|
def make_random_array(len, rand_func):
|
||||||
arr = []
|
arr = []
|
||||||
for i in range(len):
|
for i in range(len):
|
||||||
@@ -239,6 +244,7 @@ def make_random_array(len, rand_func):
|
|||||||
|
|
||||||
return arr
|
return arr
|
||||||
|
|
||||||
|
|
||||||
def make_random_2d_array(dimsize, rand_func):
|
def make_random_2d_array(dimsize, rand_func):
|
||||||
marr = []
|
marr = []
|
||||||
for i in range(dimsize[0]):
|
for i in range(dimsize[0]):
|
||||||
@@ -249,6 +255,7 @@ def make_random_2d_array(dimsize, rand_func):
|
|||||||
|
|
||||||
return marr
|
return marr
|
||||||
|
|
||||||
|
|
||||||
def make_random_3d_array(dimsize, rand_func):
|
def make_random_3d_array(dimsize, rand_func):
|
||||||
marr = []
|
marr = []
|
||||||
for i in range(dimsize[0]):
|
for i in range(dimsize[0]):
|
||||||
@@ -262,6 +269,7 @@ def make_random_3d_array(dimsize, rand_func):
|
|||||||
|
|
||||||
return marr
|
return marr
|
||||||
|
|
||||||
|
|
||||||
def prop_to_list(prop):
|
def prop_to_list(prop):
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
@@ -273,8 +281,10 @@ def prop_to_list(prop):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestArray), unittest.TestLoader().loadTestsFromTestCase(TestMArray)])
|
return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestArray), unittest.TestLoader().loadTestsFromTestCase(TestMArray)])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||||
|
Reference in New Issue
Block a user