示例#1
0
 def test_fail_superfluous_arguments(self):
     '''Failing due to superfluous arguments.'''
     infile = self.get_input('h2o.gen')
     outfile = self.get_output('h2o.isostrain.gen')
     cmdargs = ['-o', outfile, infile, '10', 'something']
     with self.assertRaises(ScriptError):
         straingen.main(cmdargs)
示例#2
0
 def test_fail_invalid_option(self):
     '''Failing due to invalid option argument'''
     infile = self.get_input('h2o.gen')
     outfile = self.get_output('h2o.isostrain.gen')
     cmdargs = ['-o', outfile, '-c', 'zx', infile, '10']
     with self.assertRaises(ScriptError):
         straingen.main(cmdargs)
示例#3
0
 def test_fail_missing_two_arguments(self):
     '''Failing due to missing argument.'''
     infile = self.get_input('h2o.gen')
     outfile = self.get_output('h2o.isostrain.gen')
     cmdargs = ['-o', outfile]
     with self.assertRaises(ScriptError):
         straingen.main(cmdargs)
示例#4
0
 def test_SuperStrain(self):
     '''Supercell with positive isotropic strain (using default)'''
     infile = self.get_input('gaas.gen')
     reffile = self.get_input('gaas.isostrain.gen')
     outfile = self.get_output('gaas.isostrain.gen')
     cmdargs = ['-o', outfile, infile, '10']
     straingen.main(cmdargs)
     self.assertTrue(common.gen_file_equals(outfile, reffile))
示例#5
0
 def test_clusterStrainXZ(self):
     '''Cluster with xz strain'''
     infile = self.get_input('h2o.gen')
     reffile = self.get_input('h2o.xz.gen')
     outfile = self.get_output('h2o.xz.gen')
     cmdargs = ['-o', outfile, '-c', 'xz', infile, '10']
     straingen.main(cmdargs)
     self.assertTrue(common.gen_file_equals(outfile, reffile))
示例#6
0
 def test_clusterStrainNegOpt(self):
     '''Cluster with negative isotropic strain (using explicit component)'''
     infile = self.get_input('h2o.gen')
     reffile = self.get_input('h2o.negisostrain.gen')
     outfile = self.get_output('h2o.negisostrain.gen')
     cmdargs = ['-o', outfile, '-c', 'I', '--', infile, '-10']
     straingen.main(cmdargs)
     self.assertTrue(common.gen_file_equals(outfile, reffile))
示例#7
0
 def test_fail_invalid_infile(self):
     '''Failing due to invalid input file.'''
     tempname = common.get_temporary_filename(self.workroot)
     nonexisting_infile = os.path.join(self.workdir, tempname)
     outfile = self.get_output('h2o.noinfile.gen')
     cmdargs = ['-o', outfile, nonexisting_infile, '10']
     with self.assertRaises(ScriptError):
         straingen.main(cmdargs)
示例#8
0
 def test_stdout(self):
     '''When output goes to stdout instead of file.'''
     infile = self.get_input('h2o.gen')
     reffile = self.get_input('h2o.isostrain.gen')
     outfile = self.get_output('h2o.isostrain.gen')
     cmdargs = [infile, '10']
     with common.OutputCatcher() as output:
         straingen.main(cmdargs)
     outfile = output.get_as_stringio()
     self.assertTrue(common.gen_file_equals(outfile, reffile))