Ver Fonte

clean up test_examples

Steven Silvester há 6 anos atrás
pai
commit
cc21211a13
1 ficheiros alterados com 24 adições e 20 exclusões
  1. 24 20
      examples/test_examples.py

+ 24 - 20
examples/test_examples.py

@@ -7,12 +7,6 @@ import sys
 
 here = osp.abspath(osp.dirname(__file__))
 
-paths = [i for i in glob.glob('%s/*' % here) if osp.isdir(i)]
-
-services_dir = osp.abspath(osp.join(here, '../packages/services/examples'))
-paths += [i for i in glob.glob('%s/*' % services_dir)]
-
-
 def header(path):
     test_name = osp.basename(path)
     print('\n')
@@ -21,21 +15,31 @@ def header(path):
     print('*' * 40)
 
 
-count = 0
-for path in sorted(paths):
-    if osp.basename(path) == 'node':
-        header(path)
-        runner = osp.join(path, 'main.py')
-        subprocess.check_call([sys.executable, runner])
+def main():
+    paths = [i for i in glob.glob('%s/*' % here) if osp.isdir(i)]
+
+    services_dir = osp.abspath(osp.join(here, '../packages/services/examples'))
+    paths += [i for i in glob.glob('%s/*' % services_dir)]
+
+    count = 0
+    for path in sorted(paths):
+        if osp.basename(path) == 'node':
+            header(path)
+            runner = osp.join(path, 'main.py')
+            subprocess.check_call([sys.executable, runner])
+            count += 1
+            continue
+
+        if not osp.exists(osp.join(path, 'main.py')):
+            continue
+
         count += 1
-        continue
+        header(path)
+        runner = osp.join(here, 'example_check.py')
+        subprocess.check_call([sys.executable, runner, path])
 
-    if not osp.exists(osp.join(path, 'main.py')):
-        continue
+    print('\n\n%s tests complete!' % count)
 
-    count += 1
-    header(path)
-    runner = osp.join(here, 'example_check.py')
-    subprocess.check_call([sys.executable, runner, path])
 
-print('\n\n%s tests complete!' % count)
+if __name__ == "__main__":
+    main()