def test_rst_ipython(self): try: import IPython except ImportError: raise unittest.SkipTest('IPython not available') result = doctests.test_rst_ipython(RST_IPYTHON, 'test_rst_ipython') self.assertEqual(result.attempted, 8) self.assertEqual(result.failed, 1) # Only the very last one.
def main(): # Not available for Python 2. import urllib.request if not os.path.exists(PANDAS_DIR): # Download the pandas source. os.makedirs(os.path.dirname(PANDAS_DIR), exist_ok=True) zip = os.path.join(PANDAS_DIR + '.zip') if not os.path.exists(zip): url = ('https://github.com/pandas-dev/pandas/archive/v%s.zip' % PANDAS_VERSION) print('Downloading', url) with urllib.request.urlopen(url) as fin: with open(zip + '.tmp', 'wb') as fout: fout.write(fin.read()) os.rename(zip + '.tmp', zip) print('Extracting', zip) with zipfile.ZipFile(zip, 'r') as handle: handle.extractall(os.path.dirname(PANDAS_DIR)) tests = sys.argv[1:] or ['getting_started', 'user_guide'] paths = [] filters = [] # Explicit paths. for test in tests: if os.path.exists(test): paths.append(test) else: filters.append(test) # Names of pandas source files. for root, _, files in os.walk(PANDAS_DOCS_SOURCE): for name in files: if name.endswith('.rst'): path = os.path.join(root, name) if any(filter in path for filter in filters): paths.append(path) # Now run all the tests. running_summary = doctests.Summary() for path in paths: with open(path) as f: rst = f.read() running_summary += doctests.test_rst_ipython(rst, path, report=True, wont_implement_ok=['*'], not_implemented_ok=['*'], use_beam=False).summary print('*' * 70) print("Final summary:") running_summary.summarize()
def run_tests(path): # Optionally capture the stdout as interleaved test errors are painful # to debug. On the other hand, if there is no parallelism, let the # output be streamed. start = time.time() with open(path) as f: rst = f.read() res = doctests.test_rst_ipython(rst, path, report=True, wont_implement_ok=['*'], not_implemented_ok=['*'], use_beam=False).summary print("Total time for {}: {:.2f} secs".format(path, time.time() - start)) return res