def setUp(self): self.folder = dcs2.get_root_dir() self.expected = argparse.Namespace() self.expected.folder = self.folder self.expected.upper = False self.expected.missing = False self.expected.unexpected_ext = False self.expected.picasa = False self.expected.long = False self.expected.resize = False self.expected.pause = False
def print_help() -> int: r""" Prints the contents of the README.rst file. Returns ------- return_code : int Return code for whether the help file was successfully loaded Examples -------- >>> from dstauffman2.commands import print_help >>> print_help() # doctest: +SKIP """ help_file = os.path.join(get_root_dir(), '..', 'README.rst') if not os.path.isfile(help_file): # pragma: no cover print(f'Warning: help file at "{help_file}" was not found.') return ReturnCodes.bad_help_file with open(help_file) as file: text = file.read() print(text) return ReturnCodes.clean
r""" Test file to execute all the docstrings within the dstauffman2 code. Notes ----- #. Written by David C. Stauffer in March 2015. """ #%% Imports import doctest import os from dstauffman2 import get_root_dir #%% Locals verbose = False #%% Execution if __name__ == '__main__': folder = get_root_dir() # TODO: include subfolders... files = [f for f in os.listdir(folder) if f.endswith('.py') and not f.startswith('__')] for file in files: if verbose: print('') print('******************************') print('******************************') print('Testing "{}":'.format(file)) doctest.testfile(os.path.join(folder, file), report=True, verbose=verbose, module_relative=True)
def test_docstrings(): r"""Tests the docstrings within this file.""" file = os.path.join(get_root_dir(), 'games', 'brick.py') doctest.testfile(file, report=True, verbose=False, module_relative=True)
if __name__ == '__main__': # flags for running code run_tests = True make_plots = True make_soln = True if run_tests: # Run docstring test test_docstrings() if make_soln: # Create and set Opts date = datetime.now() opts = Opts() opts.case_name = 'Brick' opts.save_path = os.path.join(get_root_dir(), 'results', date.strftime('%Y-%m-%d') + '_brick') opts.save_plot = True opts.show_plot = False if make_plots: setup_dir(opts.save_path, rec=True) # Solve for the center color soln[1, 1, 1] = solve_center(pieces) if make_plots: # plot the cube plot_cube(soln, title='Final Solution', opts=opts) # find all possible orientations of all pieces all_piece_combos = []
def test_function(self): folder = dcs2.get_output_dir() self.assertEqual(folder, os.path.join(dcs2.get_root_dir(), 'results'))
def test_function(self): folder = dcs2.get_images_dir() self.assertEqual(folder, os.path.join(dcs2.get_root_dir(), 'images'))
def test_function(self): folder = dcs2.get_data_dir() self.assertEqual(folder, os.path.join(dcs2.get_root_dir(), 'data'))
def test_function(self): filepath = inspect.getfile(dcs2.get_root_dir) expected_root = os.path.split(filepath)[0] folder = dcs2.get_root_dir() self.assertEqual(folder, expected_root) self.assertTrue(os.path.isdir(folder))
def setUp(self): self.folder = dcs2.get_root_dir() self.args = argparse.Namespace(folder=self.folder, upper=False, missing=False, unexpected_ext=False, \ picasa=False, long=False, resize=False, pause=False)