]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add an option to choose the IO module under test (allows to bench
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 6 Sep 2010 12:36:55 +0000 (12:36 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 6 Sep 2010 12:36:55 +0000 (12:36 +0000)
e.g. the pure Python implementation in _pyio).

Tools/iobench/iobench.py

index 92b4ffa180cb2a76f0c7c4c6ddfce001544eb658..b3bdd6a6709eebcdd1cd8ad71279b46a800f6f15 100644 (file)
@@ -427,6 +427,9 @@ def main():
                       action="store", dest="newlines", default='lf',
                       help="line endings for text tests "
                            "(one of: {lf (default), cr, crlf, all})")
+    parser.add_option("-m", "--io-module",
+                      action="store", dest="io_module", default=None,
+                      help="io module to test (default: builtin open())")
     options, args = parser.parse_args()
     if args:
         parser.error("unexpected arguments")
@@ -451,6 +454,9 @@ def main():
     if options.encoding:
         TEXT_ENCODING = options.encoding
 
+    if options.io_module:
+        globals()['open'] = __import__(options.io_module, {}, {}, ['open']).open
+
     prepare_files()
     run_all_tests(test_options)