diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gtests/blenlib/BLI_ghash_performance_test.cc | 2 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_listbase_test.cc | 218 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_ressource_strings.h | 2 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_stack_test.cc | 54 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_string_test.cc | 70 | ||||
-rw-r--r-- | tests/gtests/blenlib/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/python/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/python/bl_load_addons.py | 29 | ||||
-rw-r--r-- | tests/python/bl_load_py_modules.py | 2 | ||||
-rw-r--r-- | tests/python/bl_rna_defaults.py | 117 | ||||
-rw-r--r-- | tests/python/bl_rna_manual_reference.py (renamed from tests/python/bl_rna_wiki_reference.py) | 16 | ||||
-rw-r--r-- | tests/python/bl_rst_completeness.py | 2 | ||||
-rw-r--r-- | tests/python/bl_run_operators.py | 2 | ||||
-rw-r--r-- | tests/python/pep8.py | 13 | ||||
-rw-r--r-- | tests/python/rst_to_doctree_mini.py | 21 |
15 files changed, 525 insertions, 33 deletions
diff --git a/tests/gtests/blenlib/BLI_ghash_performance_test.cc b/tests/gtests/blenlib/BLI_ghash_performance_test.cc index ef17349268c..fcee72466b7 100644 --- a/tests/gtests/blenlib/BLI_ghash_performance_test.cc +++ b/tests/gtests/blenlib/BLI_ghash_performance_test.cc @@ -26,7 +26,7 @@ extern "C" { double q, lf, var, pempty, poverloaded; \ int bigb; \ q = BLI_ghash_calc_quality_ex((_gh), &lf, &var, &pempty, &poverloaded, &bigb); \ - printf("GHash stats (%d entries):\n\t" \ + printf("GHash stats (%u entries):\n\t" \ "Quality (the lower the better): %f\n\tVariance (the lower the better): %f\n\tLoad: %f\n\t" \ "Empty buckets: %.2f%%\n\tOverloaded buckets: %.2f%% (biggest bucket: %d)\n", \ BLI_ghash_size(_gh), q, var, lf, pempty * 100.0, poverloaded * 100.0, bigb); \ diff --git a/tests/gtests/blenlib/BLI_listbase_test.cc b/tests/gtests/blenlib/BLI_listbase_test.cc index 4b4d5d80a43..994b8f74541 100644 --- a/tests/gtests/blenlib/BLI_listbase_test.cc +++ b/tests/gtests/blenlib/BLI_listbase_test.cc @@ -3,10 +3,69 @@ #include "testing/testing.h" extern "C" { +#include "BLI_array_utils.h" #include "BLI_listbase.h" #include "MEM_guardedalloc.h" + +#include "BLI_string.h" +#include "BLI_path_util.h" +#include "BLI_ressource_strings.h" +} + + +/* local validation function */ +static bool listbase_is_valid(const ListBase *listbase) +{ +#define TESTFAIL(test) \ + if (!(test)) goto fail; + + if (listbase->first) { + const Link *prev, *link; + link = (Link *)listbase->first; + TESTFAIL(link->prev == NULL); + + link = (Link *)listbase->last; + TESTFAIL(link->next == NULL); + + prev = NULL; + link = (Link *)listbase->first; + do { + TESTFAIL(link->prev == prev); + } while ((prev = link), (link = link->next)); + TESTFAIL(prev == listbase->last); + + prev = NULL; + link = (Link *)listbase->last; + do { + TESTFAIL(link->next == prev); + } while ((prev = link), (link = link->prev)); + TESTFAIL(prev == listbase->first); + } + else { + TESTFAIL(listbase->last == NULL); + } +#undef TESTFAIL + + return true; + +fail: + return false; +} + +static int char_switch(char *string, char ch_src, char ch_dst) +{ + int tot = 0; + while (*string != 0) { + if (*string == ch_src) { + *string = ch_dst; + tot++; + } + string++; + } + return tot; } + TEST(listbase, FindLinkOrIndex) { ListBase lb; @@ -37,3 +96,162 @@ TEST(listbase, FindLinkOrIndex) BLI_freelistN(&lb); } + + +/* -------------------------------------------------------------------- */ +/* Sort utilities & test */ + +static int testsort_array_str_cmp(const void *a, const void *b) +{ + int i = strcmp(*(const char **)a, *(const char **)b); + return (i > 0) ? 1 : (i < 0) ? -1 : 0; +} + +static int testsort_listbase_str_cmp(const void *a, const void *b) +{ + const LinkData *link_a = (LinkData *)a; + const LinkData *link_b = (LinkData *)b; + int i = strcmp((const char *)link_a->data, (const char *)link_b->data); + return (i > 0) ? 1 : (i < 0) ? -1 : 0; +} + +static int testsort_array_str_cmp_reverse(const void *a, const void *b) +{ + return -testsort_array_str_cmp(a, b); +} + +static int testsort_listbase_str_cmp_reverse(const void *a, const void *b) +{ + return -testsort_listbase_str_cmp(a, b); +} + +/* check array and listbase compare */ +static bool testsort_listbase_array_str_cmp(ListBase *lb, char **arr, int arr_tot) +{ + LinkData *link_step; + int i; + + link_step = (LinkData *)lb->first; + for (i = 0; i < arr_tot; i++) { + if (strcmp(arr[i], (char *)link_step->data) != 0) { + return false; + } + link_step = link_step->next; + } + if (link_step) { + return false; + } + + return true; +} + +/* assumes nodes are allocated in-order */ +static bool testsort_listbase_sort_is_stable(ListBase *lb, bool forward) +{ + LinkData *link_step; + + link_step = (LinkData *)lb->first; + while (link_step && link_step->next) { + if (strcmp((const char *)link_step->data, (const char *)link_step->next->data) == 0) { + if ((link_step < link_step->next) != forward) { + return false; + } + } + link_step = link_step->next; + } + return true; +} + +TEST(listbase, Sort) +{ + const int words_len = sizeof(words10k) - 1; + char *words = BLI_strdupn(words10k, words_len); + int words_tot; + char **words_arr; /* qsort for comparison */ + int i; + char *w_step; + ListBase words_lb; + LinkData *words_linkdata_arr; + + /* delimit words */ + words_tot = 1 + char_switch(words, ' ', '\0'); + + words_arr = (char **)MEM_mallocN(sizeof(*words_arr) * words_tot, __func__); + + words_linkdata_arr = (LinkData *)MEM_mallocN(sizeof(*words_linkdata_arr) * words_tot, __func__); + + /* create array */ + w_step = words; + for (i = 0; i < words_tot; i++) { + words_arr[i] = w_step; + w_step += strlen(w_step) + 1; + } + + /* sort empty list */ + { + BLI_listbase_clear(&words_lb); + BLI_listbase_sort(&words_lb, testsort_listbase_str_cmp); + EXPECT_TRUE(listbase_is_valid(&words_lb)); + } + + /* sort single single */ + { + LinkData link; + link.data = words; + BLI_addtail(&words_lb, &link); + BLI_listbase_sort(&words_lb, testsort_listbase_str_cmp); + EXPECT_TRUE(listbase_is_valid(&words_lb)); + BLI_listbase_clear(&words_lb); + } + + /* create listbase */ + BLI_listbase_clear(&words_lb); + w_step = words; + for (i = 0; i < words_tot; i++) { + LinkData *link = &words_linkdata_arr[i]; + link->data = w_step; + BLI_addtail(&words_lb, link); + w_step += strlen(w_step) + 1; + } + EXPECT_TRUE(listbase_is_valid(&words_lb)); + + /* sort (forward) */ + { + qsort(words_arr, words_tot, sizeof(*words_arr), testsort_array_str_cmp); + + BLI_listbase_sort(&words_lb, testsort_listbase_str_cmp); + EXPECT_TRUE(listbase_is_valid(&words_lb)); + EXPECT_TRUE(testsort_listbase_array_str_cmp(&words_lb, words_arr, words_tot)); + EXPECT_TRUE(testsort_listbase_sort_is_stable(&words_lb, true)); + } + + /* sort (reverse) */ + { + qsort(words_arr, words_tot, sizeof(*words_arr), testsort_array_str_cmp_reverse); + + BLI_listbase_sort(&words_lb, testsort_listbase_str_cmp_reverse); + EXPECT_TRUE(listbase_is_valid(&words_lb)); + EXPECT_TRUE(testsort_listbase_array_str_cmp(&words_lb, words_arr, words_tot)); + EXPECT_TRUE(testsort_listbase_sort_is_stable(&words_lb, true)); + } + + /* sort (forward but after reversing, test stability in alternate direction) */ + { + BLI_array_reverse(words_arr, words_tot); + BLI_listbase_reverse(&words_lb); + + EXPECT_TRUE(listbase_is_valid(&words_lb)); + EXPECT_TRUE(testsort_listbase_array_str_cmp(&words_lb, words_arr, words_tot)); + EXPECT_TRUE(testsort_listbase_sort_is_stable(&words_lb, false)); + + /* and again */ + BLI_array_reverse(words_arr, words_tot); + BLI_listbase_sort(&words_lb, testsort_listbase_str_cmp_reverse); + EXPECT_TRUE(testsort_listbase_array_str_cmp(&words_lb, words_arr, words_tot)); + EXPECT_TRUE(testsort_listbase_sort_is_stable(&words_lb, false)); + } + + MEM_freeN(words); + MEM_freeN(words_arr); + MEM_freeN(words_linkdata_arr); +} diff --git a/tests/gtests/blenlib/BLI_ressource_strings.h b/tests/gtests/blenlib/BLI_ressource_strings.h index b823f14af53..d7002d748c9 100644 --- a/tests/gtests/blenlib/BLI_ressource_strings.h +++ b/tests/gtests/blenlib/BLI_ressource_strings.h @@ -3,7 +3,7 @@ #ifndef __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ #define __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ -const char *words10k = +const char words10k[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor ultrices purus tincidunt mollis. Vestibulum " "tincidunt imperdiet molestie. Vivamus posuere, risus ut mollis rutrum, lacus nulla mollis velit, consectetur auctor " "erat est in odio. Proin quis lobortis ex. Ut id quam lacus. Morbi ultrices orci quis sem suscipit tincidunt. Nullam " diff --git a/tests/gtests/blenlib/BLI_stack_test.cc b/tests/gtests/blenlib/BLI_stack_test.cc index 08701356816..44956a589dc 100644 --- a/tests/gtests/blenlib/BLI_stack_test.cc +++ b/tests/gtests/blenlib/BLI_stack_test.cc @@ -11,6 +11,14 @@ extern "C" { #define SIZE 1024 +/* number of items per chunk. use a small value to expose bugs */ +#define STACK_CHUNK_SIZE 8 + +/* Ensure block size is set to #STACK_NEW_EX_ARGS */ +#define BLI_stack_new(esize, descr) \ + BLI_stack_new_ex(esize, descr, esize * STACK_CHUNK_SIZE) + + TEST(stack, Empty) { BLI_Stack *stack; @@ -110,18 +118,60 @@ TEST(stack, Peek) EXPECT_EQ(BLI_stack_is_empty(stack), true); } +/* Check that clearing the stack leaves in it a correct state. */ +TEST(stack, Clear) +{ + const int tot_rerun = 4; + int rerun; + + /* based on range test */ + int tot = SIZE; + BLI_Stack *stack; + int in, out; + + /* use a small chunk size to ensure we test */ + stack = BLI_stack_new(sizeof(in), __func__); + + for (rerun = 0; rerun < tot_rerun; rerun++) { + for (in = 0; in < tot; in++) { + BLI_stack_push(stack, (void *)&in); + } + + BLI_stack_clear(stack); + EXPECT_EQ(BLI_stack_is_empty(stack), true); + + /* and again, this time check its valid */ + for (in = 0; in < tot; in++) { + BLI_stack_push(stack, (void *)&in); + } + + for (in = tot - 1; in >= 0; in--) { + EXPECT_EQ(BLI_stack_is_empty(stack), false); + BLI_stack_pop(stack, (void *)&out); + EXPECT_EQ(in, out); + } + + EXPECT_EQ(BLI_stack_is_empty(stack), true); + + /* without this, we wont test case when mixed free/used */ + tot /= 2; + } + + BLI_stack_free(stack); +} + TEST(stack, Reuse) { const int sizes[] = {3, 11, 81, 400, 999, 12, 1, 9721, 7, 99, 5, 0}; int sizes_test[ARRAY_SIZE(sizes)]; const int *s; - int in, out, i; + int out, i; int sum, sum_test; BLI_Stack *stack; - stack = BLI_stack_new(sizeof(in), __func__); + stack = BLI_stack_new(sizeof(i), __func__); /* add a bunch of numbers, ensure we get same sum out */ sum = 0; diff --git a/tests/gtests/blenlib/BLI_string_test.cc b/tests/gtests/blenlib/BLI_string_test.cc index 4c5c410dcb2..fa10e21730b 100644 --- a/tests/gtests/blenlib/BLI_string_test.cc +++ b/tests/gtests/blenlib/BLI_string_test.cc @@ -36,7 +36,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n) TEST(string, StrPartition) { const char delim[] = {'-', '.', '_', '~', '\\', '\0'}; - char *sep, *suf; + const char *sep, *suf; size_t pre_ln; { @@ -95,7 +95,7 @@ TEST(string, StrPartition) TEST(string, StrRPartition) { const char delim[] = {'-', '.', '_', '~', '\\', '\0'}; - char *sep, *suf; + const char *sep, *suf; size_t pre_ln; { @@ -150,11 +150,42 @@ TEST(string, StrRPartition) } } +/* BLI_str_partition_ex */ +TEST(string, StrPartitionEx) +{ + const char delim[] = {'-', '.', '_', '~', '\\', '\0'}; + const char *sep, *suf; + size_t pre_ln; + + /* Only considering 'from_right' cases here. */ + + { + const char *str = "mat.e-r_ia.l"; + + /* "mat.e-r_ia.l" over "mat.e-r" -> "mat.e", '.', "r_ia.l", 3 */ + pre_ln = BLI_str_partition_ex(str, str + 6, delim, &sep, &suf, true); + EXPECT_EQ(5, pre_ln); + EXPECT_EQ(&str[5], sep); + EXPECT_STREQ("r_ia.l", suf); + } + + /* Corner cases. */ + { + const char *str = "mate.rial"; + + /* "mate.rial" over "mate" -> "mate.rial", NULL, NULL, 4 */ + pre_ln = BLI_str_partition_ex(str, str + 4, delim, &sep, &suf, true); + EXPECT_EQ(4, pre_ln); + EXPECT_EQ(NULL, sep); + EXPECT_EQ(NULL, suf); + } +} + /* BLI_str_partition_utf8 */ TEST(string, StrPartitionUtf8) { const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'}; - char *sep, *suf; + const char *sep, *suf; size_t pre_ln; { @@ -213,7 +244,7 @@ TEST(string, StrPartitionUtf8) TEST(string, StrRPartitionUtf8) { const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'}; - char *sep, *suf; + const char *sep, *suf; size_t pre_ln; { @@ -268,6 +299,37 @@ TEST(string, StrRPartitionUtf8) } } +/* BLI_str_partition_ex_utf8 */ +TEST(string, StrPartitionExUtf8) +{ + const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'}; + const char *sep, *suf; + size_t pre_ln; + + /* Only considering 'from_right' cases here. */ + + { + const char *str = "ma\xc3\xb1te-r\xe2\x98\xafial"; + + /* "ma\xc3\xb1te-r\xe2\x98\xafial" over "ma\xc3\xb1te" -> "ma", '\xc3\xb1', "te-r\xe2\x98\xafial", 2 */ + pre_ln = BLI_str_partition_ex_utf8(str, str + 6, delim, &sep, &suf, true); + EXPECT_EQ(2, pre_ln); + EXPECT_EQ(&str[2], sep); + EXPECT_STREQ("te-r\xe2\x98\xafial", suf); + } + + /* Corner cases. */ + { + const char *str = "mate\xe2\x98\xafrial"; + + /* "mate\xe2\x98\xafrial" over "mate" -> "mate\xe2\x98\xafrial", NULL, NULL, 4 */ + pre_ln = BLI_str_partition_ex_utf8(str, str + 4, delim, &sep, &suf, true); + EXPECT_EQ(4, pre_ln); + EXPECT_EQ(NULL, sep); + EXPECT_EQ(NULL, suf); + } +} + /* BLI_str_format_int_grouped */ TEST(string, StrFormatIntGrouped) { diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt index 152b65617a4..20b876053d9 100644 --- a/tests/gtests/blenlib/CMakeLists.txt +++ b/tests/gtests/blenlib/CMakeLists.txt @@ -45,4 +45,6 @@ BLENDER_TEST(BLI_listbase "bf_blenlib") BLENDER_TEST(BLI_hash_mm2a "bf_blenlib") BLENDER_TEST(BLI_ghash "bf_blenlib") -BLENDER_TEST(BLI_ghash_performance "bf_blenlib") +if(WITH_TESTS_PERFORMANCE) + BLENDER_TEST(BLI_ghash_performance "bf_blenlib") +endif() diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index fd47bba4182..81438d357e4 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -395,6 +395,12 @@ if(WITH_CYCLES) -testdir "${TEST_SRC_DIR}/cycles/ctests/reports" -idiff "${OPENIMAGEIO_IDIFF}" ) + add_test(cycles_render_test + ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py + -blender "${TEST_BLENDER_EXE_BARE}" + -testdir "${TEST_SRC_DIR}/cycles/ctests/render" + -idiff "${OPENIMAGEIO_IDIFF}" + ) add_test(cycles_shaders_test ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py -blender "${TEST_BLENDER_EXE_BARE}" diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py index 227edf4164d..29304400005 100644 --- a/tests/python/bl_load_addons.py +++ b/tests/python/bl_load_addons.py @@ -34,11 +34,29 @@ import imp BLACKLIST_DIRS = ( os.path.join(bpy.utils.resource_path('USER'), "scripts"), ) + tuple(addon_utils.paths()[1:]) +BLACKLIST_ADDONS = set() + + +def _init_addon_blacklist(): + + # in case we built without cycles + if not bpy.app.build_options.cycles: + BLACKLIST_ADDONS.add("cycles") + + # in case we built without freestyle + if not bpy.app.build_options.freestyle: + BLACKLIST_ADDONS.add("render_freestyle_svg") + + # netrender has known problems re-registering + BLACKLIST_ADDONS.add("netrender") def addon_modules_sorted(): modules = addon_utils.modules({}) - modules[:] = [mod for mod in modules if not mod.__file__.startswith(BLACKLIST_DIRS)] + modules[:] = [ + mod for mod in modules + if not (mod.__file__.startswith(BLACKLIST_DIRS)) + if not (mod.__name__ in BLACKLIST_ADDONS)] modules.sort(key=lambda mod: mod.__name__) return modules @@ -47,7 +65,7 @@ def disable_addons(): # first disable all addons = bpy.context.user_preferences.addons for mod_name in list(addons.keys()): - addon_utils.disable(mod_name) + addon_utils.disable(mod_name, default_set=True) assert(bool(addons) is False) @@ -64,7 +82,7 @@ def test_load_addons(): mod_name = mod.__name__ print("\tenabling:", mod_name) addon_utils.enable(mod_name, default_set=True) - if mod_name not in addons: + if (mod_name not in addons) and (mod_name not in BLACKLIST_ADDONS): addons_fail.append(mod_name) if addons_fail: @@ -93,7 +111,7 @@ def reload_addons(do_reload=True, do_reverse=True): for mod in modules: mod_name = mod.__name__ print("\tdisabling:", mod_name) - addon_utils.disable(mod_name) + addon_utils.disable(mod_name, default_set=True) assert(not (mod_name in addons)) # now test reloading @@ -106,6 +124,9 @@ def reload_addons(do_reload=True, do_reverse=True): def main(): + + _init_addon_blacklist() + # first load addons, print a list of all addons that fail test_load_addons() diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py index 07905dfa4b4..d4285155000 100644 --- a/tests/python/bl_load_py_modules.py +++ b/tests/python/bl_load_py_modules.py @@ -68,7 +68,7 @@ def load_addons(): # first disable all for mod_name in list(addons.keys()): - addon_utils.disable(mod_name) + addon_utils.disable(mod_name, default_set=True) assert(bool(addons) is False) diff --git a/tests/python/bl_rna_defaults.py b/tests/python/bl_rna_defaults.py new file mode 100644 index 00000000000..1d6f82b06c2 --- /dev/null +++ b/tests/python/bl_rna_defaults.py @@ -0,0 +1,117 @@ +# Apache License, Version 2.0 + +# ./blender.bin --background -noaudio --factory-startup --python tests/python/bl_rna_defaults.py + +import bpy + +DUMMY_NAME = "Untitled" +DUMMY_PATH = __file__ +GLOBALS = { + "error_num": 0, + } + + +def validate_defaults(test_id, o): + + def warning(prop_id, val_real, val_default): + print("Error %s: '%s.%s' is:%r, expected:%r" % + (test_id, o.__class__.__name__, prop_id, val_real, val_default)) + GLOBALS["error_num"] += 1 + + properties = type(o).bl_rna.properties.items() + for prop_id, prop in properties: + if prop_id == "rna_type": + continue + prop_type = prop.type + if prop_type in {'STRING', 'COLLECTION'}: + continue + + if prop_type == 'POINTER': + # traverse down pointers if they're set + val_real = getattr(o, prop_id) + if (val_real is not None) and (not isinstance(val_real, bpy.types.ID)): + validate_defaults("%s.%s" % (test_id, prop_id), val_real) + elif prop_type in {'INT', 'BOOL'}: + array_length = prop.array_length + if array_length == 0: + val_real = getattr(o, prop_id) + val_default = prop.default + if val_real != val_default: + warning(prop_id, val_real, val_default) + else: + pass # TODO, array defaults + elif prop_type == 'FLOAT': + array_length = prop.array_length + if array_length == 0: + val_real = getattr(o, prop_id) + val_default = prop.default + if val_real != val_default: + warning(prop_id, val_real, val_default) + else: + pass # TODO, array defaults + elif prop_type == 'ENUM': + val_real = getattr(o, prop_id) + if prop.is_enum_flag: + val_default = prop.default_flag + else: + val_default = prop.default + if val_real != val_default: + warning(prop_id, val_real, val_default) + + # print(prop_id, prop_type) + + +def _test_id_gen(data_attr, args_create=(DUMMY_NAME,), create_method="new"): + def test_gen(test_id): + id_collection = getattr(bpy.data, data_attr) + create_fn = getattr(id_collection, create_method) + o = create_fn(*args_create) + o.user_clear() + validate_defaults(test_id, o) + id_collection.remove(o) + return test_gen + + +test_Action = _test_id_gen("actions") +test_Armature = _test_id_gen("armatures") +test_Camera = _test_id_gen("cameras") +test_Group = _test_id_gen("groups") +test_Lattice = _test_id_gen("lattices") +test_LineStyle = _test_id_gen("linestyles") +test_Mask = _test_id_gen("masks") +test_Material = _test_id_gen("materials") +test_Mesh = _test_id_gen("meshes") +test_MetaBall = _test_id_gen("metaballs") +test_MovieClip = _test_id_gen("movieclips", args_create=(DUMMY_PATH,), create_method="load") +test_Object = _test_id_gen("objects", args_create=(DUMMY_NAME, None)) +test_Palette = _test_id_gen("palettes") +test_Particle = _test_id_gen("particles") +test_Scene = _test_id_gen("scenes") +test_Sound = _test_id_gen("sounds", args_create=(DUMMY_PATH,), create_method="load") +test_Speaker = _test_id_gen("speakers") +test_Text = _test_id_gen("texts") +test_VectorFont = _test_id_gen("fonts", args_create=("<builtin>",), create_method="load") +test_World = _test_id_gen("worlds") + +ns = globals() +for t in bpy.data.curves.bl_rna.functions["new"].parameters["type"].enum_items.keys(): + ns["test_Curve_%s" % t] = _test_id_gen("curves", args_create=(DUMMY_NAME, t)) +for t in bpy.data.lamps.bl_rna.functions["new"].parameters["type"].enum_items.keys(): + ns["test_Lamp_%s" % t] = _test_id_gen("lamps", args_create=(DUMMY_NAME, t)) +# types are a dynamic enum, have to hard-code. +for t in "ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree": + ns["test_NodeGroup_%s" % t] = _test_id_gen("node_groups", args_create=(DUMMY_NAME, t)) +for t in bpy.data.textures.bl_rna.functions["new"].parameters["type"].enum_items.keys(): + ns["test_Texture_%s" % t] = _test_id_gen("textures", args_create=(DUMMY_NAME, t)) +del ns + + +def main(): + for fn_id, fn_val in sorted(globals().items()): + if fn_id.startswith("test_") and callable(fn_val): + fn_val(fn_id) + + print("Error (total): %d" % GLOBALS["error_num"]) + +if __name__ == "__main__": + main() diff --git a/tests/python/bl_rna_wiki_reference.py b/tests/python/bl_rna_manual_reference.py index a637f6d555c..c67b6c1532b 100644 --- a/tests/python/bl_rna_wiki_reference.py +++ b/tests/python/bl_rna_manual_reference.py @@ -18,8 +18,8 @@ # <pep8 compliant> -# Use for validating our wiki interlinking. -# ./blender.bin --background -noaudio --python tests/python/bl_rna_wiki_reference.py +# Use for validating our manual interlinking. +# ./blender.bin --background -noaudio --python tests/python/bl_rna_manual_reference.py # # 1) test_data() -- ensure the data we have is correct format # 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path @@ -31,10 +31,10 @@ import bpy def test_data(): - import rna_wiki_reference + import rna_manual_reference - assert(isinstance(rna_wiki_reference.url_manual_mapping, tuple)) - for i, value in enumerate(rna_wiki_reference.url_manual_mapping): + assert(isinstance(rna_manual_reference.url_manual_mapping, tuple)) + for i, value in enumerate(rna_manual_reference.url_manual_mapping): try: assert(len(value) == 2) assert(isinstance(value[0], str)) @@ -94,7 +94,7 @@ def test_language_coverage(): def test_urls(): import os import sys - import rna_wiki_reference + import rna_manual_reference import urllib.error from urllib.request import urlopen @@ -102,9 +102,9 @@ def test_urls(): # avoid URL lookups if possible LOCAL_PREFIX = os.environ.get("LOCAL_PREFIX") if LOCAL_PREFIX is None: - prefix = rna_wiki_reference.url_manual_prefix + prefix = rna_manual_reference.url_manual_prefix - urls = {suffix for (rna_id, suffix) in rna_wiki_reference.url_manual_mapping} + urls = {suffix for (rna_id, suffix) in rna_manual_reference.url_manual_mapping} urls_len = "%d" % len(urls) print("") diff --git a/tests/python/bl_rst_completeness.py b/tests/python/bl_rst_completeness.py index d0ba2c552cf..d8dfac66d13 100644 --- a/tests/python/bl_rst_completeness.py +++ b/tests/python/bl_rst_completeness.py @@ -62,7 +62,7 @@ def is_directive_pydata(filepath, directive): return True elif directive.type in {"module", "note", "warning", "code-block", "hlist", "seealso"}: return False - elif directive.type in {"literalinclude"}: # TODO + elif directive.type == "literalinclude": # TODO return False else: print(directive_to_str(filepath, directive), end=" ") diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py index d511cd19ff7..f3c553cf3ef 100644 --- a/tests/python/bl_run_operators.py +++ b/tests/python/bl_run_operators.py @@ -163,7 +163,7 @@ if USE_ATTRSET: if issubclass(cls, skip_classes): continue - ## to support skip-save we cant get all props + # # to support skip-save we cant get all props # properties = cls.bl_rna.properties.keys() properties = [] for prop_id, prop in cls.bl_rna.properties.items(): diff --git a/tests/python/pep8.py b/tests/python/pep8.py index 551e2a87e9b..0d6db729767 100644 --- a/tests/python/pep8.py +++ b/tests/python/pep8.py @@ -117,7 +117,18 @@ def main(): # these are very picky and often hard to follow # while keeping common script formatting. - ignore = "E122", "E123", "E124", "E125", "E126", "E127", "E128" + ignore = ( + "E122", + "E123", + "E124", + "E125", + "E126", + "E127", + "E128", + # "imports not at top of file." + # prefer to load as needed (lazy load addons etc). + "E402", + ) for f, pep8_type in files: diff --git a/tests/python/rst_to_doctree_mini.py b/tests/python/rst_to_doctree_mini.py index 6a885a108f8..dfc6cd57db6 100644 --- a/tests/python/rst_to_doctree_mini.py +++ b/tests/python/rst_to_doctree_mini.py @@ -28,13 +28,14 @@ import collections -Directive = collections.namedtuple('Directive', - ("type", - "value", - "value_strip", - "line", - "indent", - "members")) +Directive = collections.namedtuple( + "Directive", + ("type", + "value", + "value_strip", + "line", + "indent", + "members")) def parse_rst_py(filepath): @@ -80,7 +81,7 @@ def parse_rst_py(filepath): return tree[0] -if __name__ == "__main__": +def main(): # not intended use, but may as well print rst files passed as a test. import sys for arg in sys.argv: @@ -88,3 +89,7 @@ if __name__ == "__main__": items = parse_rst_py(arg) for i in items: print(i) + + +if __name__ == "__main__": + main() |