Коммит 35956091 создал по автору Ilya Portnov's avatar Ilya Portnov
Просмотр файлов

Test documentation references consistence.

владелец d43132c8
......@@ -5,6 +5,6 @@ Alpha Nodes
.. toctree::
:maxdepth: 2
offset_line
contour2D
planar_edgenet_to_polygons
armature_analyzer
lattice_analyzer
......@@ -6,7 +6,7 @@ Analyzers
:maxdepth: 2
area
bbox
bbox_mk2
diameter
distance_pp
distance_point_line
......@@ -32,5 +32,5 @@ Analyzers
points_inside_mesh
polygons_centers
polygons_centers_mk3
raycast
volume
raycaster_lite
......@@ -12,4 +12,8 @@ Beta Nodes
sample_uv_color
color_by_formula
spiralNode
unsubdivide
deform_by_formula
extrude_separate_lite
subdivide_lite
......@@ -11,8 +11,9 @@ Generators
bricks
circle
cylinder
cylinder_mk2
image
line_mk2
line_mk3
ngon
plane_mk2
random_vector_mk2
......
......@@ -11,9 +11,10 @@ Generators Extended
hilbert
hilbert3d
hilbert_image
hexa_grid_mk1
polygon_grid
image_components
profile_mk2
profile_mk3
regular_solid
mesh_eval
ring
......@@ -22,4 +23,6 @@ Generators Extended
scripted_intro
script_mk2
smooth_lines
\ Нет новой строки в конце файла
ellipse
super_ellipsoid
......@@ -13,3 +13,4 @@ List Main
match
sum_mk2
zip
statistics
......@@ -6,3 +6,5 @@ List Mutators
:maxdepth: 2
modifier
polygon_sort
combinatorics
......@@ -8,3 +8,4 @@ Logic
logic_node
neuro_elman
switch
input_switch
......@@ -16,3 +16,4 @@ Matrix
matrix_track_to
shear
matrix_normal
iterate
......@@ -15,16 +15,12 @@ Modifier Change
extrude_separate
extrude_region
holes_fill
iterate
mesh_join
mesh_separate
objects_along_edge
bend_along_path
bend_along_surface
offset
polygons_boom
polygons_to_edges
randomize
recalc_normals
remove_doubles
triangulate
......
......@@ -19,3 +19,7 @@ Modifier Make
voronoi_2d
wafel
wireframe
offset_line
bevel_curve
contour2D
fractal_curve
......@@ -10,10 +10,12 @@ Number
float
float_to_int
formula2
formula3
integer
list_input
mix_numbers
random
random_num_gen
range_float
range_int
range_map
......
......@@ -13,4 +13,4 @@ Text
shape
text_in_mk2
text_out
viewer_text_mk2
viewer_text_mk3
......@@ -25,3 +25,5 @@ Vector
vertices_sort
variable_lacunarity
turbulence
linear_approx
color_input
from os.path import basename, splitext, dirname, join, exists
from os import walk
import sverchok
from sverchok.utils.testing import *
from sverchok.utils.logging import debug, info, error
class DocumentationTests(SverchokTestCase):
def test_all_node_docs_in_trees(self):
"""
Check that each node documentation file is mentioned in corresponding index file.
"""
def check(index_file_path, doc_file_path):
(name, ext) = splitext(basename(doc_file_path))
found = False
with open(index_file_path, 'r') as index:
for line in index:
line = line.strip()
if line == name:
found = True
break
return found
def check_dir(directory, fnames):
dir_name = basename(directory)
index_name = dir_name + "_index.rst"
index_file_path = join(directory, index_name)
bad_files = []
for fname in fnames:
if fname.endswith("_index.rst"):
continue
if not check(index_file_path, fname):
bad_files.append(fname)
if bad_files:
error("The following files are not mentioned in %s:\n%s", index_name, "\n".join(bad_files))
self.fail("Not all node documentation files are mentioned in their corresponding indexes.")
sv_init = sverchok.__file__
docs_dir = join(dirname(sv_init), "docs", "nodes")
for directory, subdirs, fnames in walk(docs_dir):
with self.subTest(directory=basename(directory)):
check_dir(directory, fnames)
def test_node_docs_refs_from_trees(self):
def check_dir(directory):
dir_name = basename(directory)
index_name = dir_name + "_index.rst"
index_file_path = join(directory, index_name)
bad_files = []
if exists(index_file_path):
with open(index_file_path, 'r') as index:
start = False
for line in index:
line = line.strip()
if not line:
continue
if ":maxdepth:" in line:
start = True
continue
if not start:
continue
doc_name = line + ".rst"
doc_path = join(directory, doc_name)
if not exists(doc_path):
bad_files.append(doc_name)
if bad_files:
error("The following files, which are referenced from %s, do not exist:\n%s", index_name, "\n".join(bad_files))
self.fail("Not all node documentation referenced from index files exist.")
sv_init = sverchok.__file__
docs_dir = join(dirname(sv_init), "docs", "nodes")
for directory, subdirs, fnames in walk(docs_dir):
with self.subTest(directory=basename(directory)):
check_dir(directory)
......@@ -160,18 +160,21 @@ def get_tests_path():
tests_dir = join(dirname(sv_init), "tests")
return tests_dir
def run_all_tests():
def run_all_tests(pattern=None):
"""
Run all existing test cases.
Test cases are looked up under tests/ directory.
"""
if pattern is None:
pattern = "*_tests.py"
tests_path = get_tests_path()
log_handler = logging.FileHandler(join(tests_path, "sverchok_tests.log"), mode='w')
logging.getLogger().addHandler(log_handler)
try:
loader = unittest.TestLoader()
suite = loader.discover(start_dir = tests_path, pattern = "*_tests.py")
suite = loader.discover(start_dir = tests_path, pattern = pattern)
buffer = StringIO()
runner = unittest.TextTestRunner(stream = buffer, verbosity=2)
result = runner.run(suite)
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать