def test_define_variables_on_indentation_error(self): first = ''' a = 1 --- b = 2 --- c = 3 --- \td = 4 --- \t e = 5 ''' for first in first.split('---'): with self.assertRaises(IndentationError): _out(define_variables(_in(first), self.target()))
def test_define_variables_on_syntax_error(self): first = ''' = --- a= --- =b --- 1a = 1 --- a, b = 2, 3 --- auto = 1 --- none = 1 --- Px = 1 ''' for first in first.split('---'): with self.assertRaises(SyntaxError): _out(define_variables(_in(first), self.target()))
def test_define_variables(self): first = ''' a = 1 b = 2 --- input["type"="radio"] --- e = 'string' ''' second = [ (4, 'input["type"="radio"]'), ] second1 = [ (1, 'a = 1'), (2, 'b = 2'), (6, "e = 'string'"), ] first = _out(define_variables(_in(first), self.target())) self.assertDictContainsSubset({'a': 1, 'b': 2, 'e': 'string'}, _locals) self.assertEqual(first, second) self.assertListEqual(_out(self.first), second1)