Skip to content

Commit

Permalink
Change related tests #1186
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Jan 25, 2019
1 parent d6edc18 commit 0bf889f
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,20 +524,25 @@ def testParameters(self):
wf = script.workflow()
self.assertEqual(sorted(list(wf.parameters().keys())), ['a_b', 'c_b'])

# this test is no longer valid because sos has stopped parsing assignments
#
# def testSectionVariables(self):
# '''Test variables in sections'''
# # directive name cannot be used as variable
# self.assertRaises(ParsingError, SoS_Script,
# '''[0]
# input='a.txt' ''')
# self.assertRaises(ParsingError, SoS_Script,
# '''[0]
# output='a.txt' ''')
# self.assertRaises(ParsingError, SoS_Script,
# '''[0]
# depends='a.txt' ''')
def testParamInTask(self):
'''Test specification of parameters in tasks'''
self.assertRaises(Exception, SoS_Script, '''\
[1]
output: 'a.txt'
task:
parameter: value = 'a'
sh: expand=True
echo {value} > a.txt
''')
# multiple parameters
script = SoS_Script('''
parameter: a_b = int
[0]
parameter: c_b = list
''')
wf = script.workflow()
self.assertEqual(sorted(list(wf.parameters().keys())), ['a_b', 'c_b'])


def testTypeTraitParameter(self):
# type trait
Expand Down Expand Up @@ -1659,10 +1664,10 @@ def testNamedOutputInDepends(self):
_output.touch()
[default]
dpends: named_output('A')
depends: named_output('A')
''')
wf = script.workflow()
self.assertRaises(Exception, Base_Executor(wf).run)
Base_Executor(wf).run()

def testOutputFromInDepends(self):
'''Test output_from in depends statement'''
Expand All @@ -1672,33 +1677,33 @@ def testOutputFromInDepends(self):
_output.touch()
[default]
dpends: output_from('A')
depends: output_from('A')
''')
wf = script.workflow()
self.assertRaises(Exception, Base_Executor(wf).run)
Base_Executor(wf).run()

def testNamedOutputInOutput(self):
'''Test named_output in output statement'''
script = SoS_Script('''
[A]
output: A='a.txt'
output: Aa='a.txt'
_output.touch()
[default]
output: named_output('A')
output: named_output('Aa')
''')
wf = script.workflow()
self.assertRaises(Exception, Base_Executor(wf).run)

def testOutputFromInOutput(self):
'''Test output_from in output statement'''
script = SoS_Script('''
[A]
[Aa]
output: A='a.txt'
_output.touch()
[default]
output: output_from('A')
output: output_from('Aa')
''')
wf = script.workflow()
self.assertRaises(Exception, Base_Executor(wf).run)
Expand Down

0 comments on commit 0bf889f

Please sign in to comment.