def setUp(self): self.line = 'weights-file = test/parser/weights # foo bar' self.args = Mock() self.args.origdir = JOSHUA_PATH self.args.destdir = '/tmp/testdestdir' if os.path.exists(self.args.destdir): clear_non_empty_dir(self.args.destdir) os.mkdir(self.args.destdir)
def setUp(self): # N.B. specify a path to copytree that is not inside you application. # Otherwise it ends with an infinite recursion. self.line = 'tm = thrax pt 12 example # foo bar' self.args = Mock() self.args.origdir = os.path.join(JOSHUA_PATH, 'examples') self.args.destdir = './testdestdir' # Create the destination directory. if os.path.exists(self.args.destdir): clear_non_empty_dir(self.args.destdir) os.mkdir(self.args.destdir) CopyFileConfigLine.clear_file_name_counts()
def setUp(self): CopyFileConfigLine.clear_file_name_counts() self.line = 'weights-file = weights # foo bar\noutput-format = %1' self.origdir = '/tmp/testorigdir' self.destdir = '/tmp/testdestdir' for d in [self.origdir, self.destdir]: if os.path.exists(d): clear_non_empty_dir(d) # Create the destination directory. os.mkdir(self.origdir) os.mkdir(self.destdir) # Write the files to be processed. config_file = os.path.join(self.origdir, 'joshua.config') with open(config_file, 'w') as fh: fh.write(self.line) with open(os.path.join(self.origdir, 'weights'), 'w') as fh: fh.write("grammar data\n") self.args = ['thisprogram', '-f', config_file, self.origdir, self.destdir]
def setUp(self): CopyFileConfigLine.clear_file_name_counts() self.line = 'weights-file = weights # foo bar\noutput-format = %1' self.origdir = '/tmp/testorigdir' self.destdir = '/tmp/testdestdir' for d in [self.origdir, self.destdir]: if os.path.exists(d): clear_non_empty_dir(d) # Create the destination directory. os.mkdir(self.origdir) os.mkdir(self.destdir) # Write the files to be processed. config_file = os.path.join(self.origdir, 'joshua.config') with open(config_file, 'w') as fh: fh.write(self.line) with open(os.path.join(self.origdir, 'weights'), 'w') as fh: fh.write("grammar data\n") self.args = [ 'thisprogram', '-f', config_file, self.origdir, self.destdir ]
def test_clear_non_empty_dir(self): clear_non_empty_dir(self.test_dest_dir) self.assertFalse(os.path.exists(self.test_dest_dir))
def tearDown(self): if os.path.exists(self.test_dest_dir): clear_non_empty_dir(self.test_dest_dir) pass
def tearDown(self): for d in [self.origdir, self.destdir]: if os.path.exists(d): clear_non_empty_dir(d)
def tearDown(self): if os.path.exists(self.args.destdir): clear_non_empty_dir(self.args.destdir)
def test_make_dest_dir__non_extant(self): # Set up by removing (existing) directory. clear_non_empty_dir(self.test_dest_dir) # A new empty directory should be created. make_dest_dir(self.test_dest_dir, False) self.assertTrue(os.path.exists(self.test_dest_dir))