(path, module_relative=True, package=None,
globs=None, parser=DocTestParser(),
encoding=None, **options)
| 2453 | ) |
| 2454 | |
| 2455 | def DocFileTest(path, module_relative=True, package=None, |
| 2456 | globs=None, parser=DocTestParser(), |
| 2457 | encoding=None, **options): |
| 2458 | if globs is None: |
| 2459 | globs = {} |
| 2460 | else: |
| 2461 | globs = globs.copy() |
| 2462 | |
| 2463 | if package and not module_relative: |
| 2464 | raise ValueError("Package may only be specified for module-" |
| 2465 | "relative paths.") |
| 2466 | |
| 2467 | # Relativize the path. |
| 2468 | doc, path = _load_testfile(path, package, module_relative, |
| 2469 | encoding or "utf-8") |
| 2470 | |
| 2471 | if "__file__" not in globs: |
| 2472 | globs["__file__"] = path |
| 2473 | |
| 2474 | # Find the file and read it. |
| 2475 | name = os.path.basename(path) |
| 2476 | |
| 2477 | # Convert it to a test, and wrap it in a DocFileCase. |
| 2478 | test = parser.get_doctest(doc, globs, name, path, 0) |
| 2479 | return DocFileCase(test, **options) |
| 2480 | |
| 2481 | def DocFileSuite(*paths, **kw): |
| 2482 | """A unittest suite for one or more doctest files. |
no test coverage detected