cmark

My personal build of CMark ✏️

Commit
6b64a95713fc8a045f8e40949cec0765e0acb9b8
Parent
572557dd3ca0cedecba3833111bb04bb5668db43
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Remove useless __name__ check in test scripts

These checks don't seem to be required and broke pathological_tests.py on Windows where multiprocessing sets __name__ to "__mp_main__".

Diffstat

4 files changed, 48 insertions, 52 deletions

Status File Name N° Changes Insertions Deletions
Modified test/entity_tests.py 13 6 7
Modified test/pathological_tests.py 13 6 7
Modified test/roundtrip_tests.py 31 15 16
Modified test/spec_tests.py 43 21 22
diff --git a/test/entity_tests.py b/test/entity_tests.py
@@ -19,13 +19,12 @@ def get_entities():
         entities.append((entity, utf8))
     return entities
 
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description='Run cmark tests.')
-    parser.add_argument('--program', dest='program', nargs='?', default=None,
-            help='program to test')
-    parser.add_argument('--library-dir', dest='library_dir', nargs='?',
-            default=None, help='directory containing dynamic library')
-    args = parser.parse_args(sys.argv[1:])
+parser = argparse.ArgumentParser(description='Run cmark tests.')
+parser.add_argument('--program', dest='program', nargs='?', default=None,
+        help='program to test')
+parser.add_argument('--library-dir', dest='library_dir', nargs='?',
+        default=None, help='directory containing dynamic library')
+args = parser.parse_args(sys.argv[1:])
 
 cmark = CMark(prog=args.program, library_dir=args.library_dir)
 
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
@@ -9,13 +9,12 @@ import multiprocessing
 import time
 from cmark import CMark
 
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description='Run cmark tests.')
-    parser.add_argument('--program', dest='program', nargs='?', default=None,
-            help='program to test')
-    parser.add_argument('--library-dir', dest='library_dir', nargs='?',
-            default=None, help='directory containing dynamic library')
-    args = parser.parse_args(sys.argv[1:])
+parser = argparse.ArgumentParser(description='Run cmark tests.')
+parser.add_argument('--program', dest='program', nargs='?', default=None,
+        help='program to test')
+parser.add_argument('--library-dir', dest='library_dir', nargs='?',
+        default=None, help='directory containing dynamic library')
+args = parser.parse_args(sys.argv[1:])
 
 allowed_failures = {"many references": True}
 
diff --git a/test/roundtrip_tests.py b/test/roundtrip_tests.py
@@ -4,22 +4,21 @@ from spec_tests import get_tests, do_test
 from cmark import CMark
 import argparse
 
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description='Run cmark roundtrip tests.')
-    parser.add_argument('-p', '--program', dest='program', nargs='?', default=None,
-            help='program to test')
-    parser.add_argument('-s', '--spec', dest='spec', nargs='?', default='spec.txt',
-            help='path to spec')
-    parser.add_argument('-P', '--pattern', dest='pattern', nargs='?',
-            default=None, help='limit to sections matching regex pattern')
-    parser.add_argument('--library-dir', dest='library_dir', nargs='?',
-            default=None, help='directory containing dynamic library')
-    parser.add_argument('--no-normalize', dest='normalize',
-            action='store_const', const=False, default=True,
-            help='do not normalize HTML')
-    parser.add_argument('-n', '--number', type=int, default=None,
-            help='only consider the test with the given number')
-    args = parser.parse_args(sys.argv[1:])
+parser = argparse.ArgumentParser(description='Run cmark roundtrip tests.')
+parser.add_argument('-p', '--program', dest='program', nargs='?', default=None,
+        help='program to test')
+parser.add_argument('-s', '--spec', dest='spec', nargs='?', default='spec.txt',
+        help='path to spec')
+parser.add_argument('-P', '--pattern', dest='pattern', nargs='?',
+        default=None, help='limit to sections matching regex pattern')
+parser.add_argument('--library-dir', dest='library_dir', nargs='?',
+        default=None, help='directory containing dynamic library')
+parser.add_argument('--no-normalize', dest='normalize',
+        action='store_const', const=False, default=True,
+        help='do not normalize HTML')
+parser.add_argument('-n', '--number', type=int, default=None,
+        help='only consider the test with the given number')
+args = parser.parse_args(sys.argv[1:])
 
 spec = sys.argv[1]
 
diff --git a/test/spec_tests.py b/test/spec_tests.py
@@ -9,28 +9,27 @@ import json
 from cmark import CMark
 from normalize import normalize_html
 
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description='Run cmark tests.')
-    parser.add_argument('-p', '--program', dest='program', nargs='?', default=None,
-            help='program to test')
-    parser.add_argument('-s', '--spec', dest='spec', nargs='?', default='spec.txt',
-            help='path to spec')
-    parser.add_argument('-P', '--pattern', dest='pattern', nargs='?',
-            default=None, help='limit to sections matching regex pattern')
-    parser.add_argument('--library-dir', dest='library_dir', nargs='?',
-            default=None, help='directory containing dynamic library')
-    parser.add_argument('--no-normalize', dest='normalize',
-            action='store_const', const=False, default=True,
-            help='do not normalize HTML')
-    parser.add_argument('-d', '--dump-tests', dest='dump_tests',
-            action='store_const', const=True, default=False,
-            help='dump tests in JSON format')
-    parser.add_argument('--debug-normalization', dest='debug_normalization',
-            action='store_const', const=True,
-            default=False, help='filter stdin through normalizer for testing')
-    parser.add_argument('-n', '--number', type=int, default=None,
-            help='only consider the test with the given number')
-    args = parser.parse_args(sys.argv[1:])
+parser = argparse.ArgumentParser(description='Run cmark tests.')
+parser.add_argument('-p', '--program', dest='program', nargs='?', default=None,
+        help='program to test')
+parser.add_argument('-s', '--spec', dest='spec', nargs='?', default='spec.txt',
+        help='path to spec')
+parser.add_argument('-P', '--pattern', dest='pattern', nargs='?',
+        default=None, help='limit to sections matching regex pattern')
+parser.add_argument('--library-dir', dest='library_dir', nargs='?',
+        default=None, help='directory containing dynamic library')
+parser.add_argument('--no-normalize', dest='normalize',
+        action='store_const', const=False, default=True,
+        help='do not normalize HTML')
+parser.add_argument('-d', '--dump-tests', dest='dump_tests',
+        action='store_const', const=True, default=False,
+        help='dump tests in JSON format')
+parser.add_argument('--debug-normalization', dest='debug_normalization',
+        action='store_const', const=True,
+        default=False, help='filter stdin through normalizer for testing')
+parser.add_argument('-n', '--number', type=int, default=None,
+        help='only consider the test with the given number')
+args = parser.parse_args(sys.argv[1:])
 
 def out(str):
     sys.stdout.buffer.write(str.encode('utf-8'))