def setup_directories(self): with no_stderrout(): remove_dir(['test/external/', 'test/input/']) clear_dir(['test/output/', 'test/log/']) if not os.path.isdir('test/raw/move_sources/dir/'): os.makedirs('test/raw/move_sources/dir/')
def tearDown(self): if os.path.isdir('test/output/'): shutil.rmtree('test/output/') if os.path.isdir('test/log/'): shutil.rmtree('test/log/') if os.path.isdir('test/input/'): remove_dir(['test/input/'], quiet = True) if os.path.isdir('test/external/'): shutil.rmtree('test/external/')
def test_quiet(self): self.make_output() # Redirect stdout with open('test/stdout.txt', 'w') as f: with redirect_stdout(f): remove_dir(['test/output/'], quiet=True) # Check stdout self.assertNotIn('Removed:', read_file('test/stdout.txt'))
def test_dir_not_exist(self): """ Note ---- When removing a directory that does not exist, nothing is ever printed. """ self.assertFalse(os.path.exists('test/output/')) # Redirect stdout with open('test/stdout.txt', 'w') as f: with redirect_stdout(f): remove_dir(['test/output/'], quiet=False) # Check stdout self.assertNotIn('Removed:', read_file('test/stdout.txt')) self.check_output()
import gslab_make as gs ### PULL PATHS FROM CONFIG PATHS = {'root': ROOT, 'config': os.path.join(ROOT, 'config.yaml')} PATHS = gs.update_internal_paths(PATHS) ### LOAD CONFIG USER PATHS = gs.update_external_paths(PATHS) gs.update_executables(PATHS) ############ ### MAKE ### ############ ### START MAKE gs.remove_dir(['input', 'external']) gs.clear_dir(['output', 'log']) gs.start_makelog(PATHS) ### MAKE LINKS TO INPUT AND EXTERNAL FILES inputs = gs.link_inputs(PATHS, ['input.txt']) externals = gs.link_externals(PATHS, ['external.txt']) gs.write_source_logs(PATHS, inputs + externals) gs.get_modified_sources(PATHS, inputs + externals) ### RUN SCRIPTS gs.run_stata(PATHS, 'code/analyze_data.do') ### LOG OUTPUTS gs.log_files_in_output(PATHS)
def setUp(self): with no_stderrout(): remove_dir(['test/input/']) clear_dir(['test/log/'])
def test_error_file(self): self.make_output(contain_file=True) with self.assertRaises(Exception): remove_dir(['test/output/file.txt'], quiet=True)
def test_non_list(self): self.make_output() remove_dir('test/output/', quiet=True) self.check_output()
def test_wildcard(self): self.make_output() remove_dir(['test/outpu*/'], quiet=True) self.check_output()
def test_dir_with_files(self): self.make_output(contain_file=True) remove_dir(['test/output/'], quiet=True) self.check_output()
def test_dir(self): self.make_output() remove_dir(['test/output/'], quiet=True) self.check_output()