git @ Cat's Eye Technologies Falderal / 8ba911e
Convert the remainder of the tests. Chris Pressey 3 years ago
2 changed file(s) with 32 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
191191 def __unicode__(self):
192192 return unicode(repr(self))
193193
194 def __eq__(self, other):
195 return (
196 self.__class__ == other.__class__ and
197 self.lines == other.lines and
198 self.line_num == other.line_num and
199 self.filename == other.filename
200 )
201
202194 def location(self):
203195 filename = self.filename
204196 if filename is None:
550542
551543 def __unicode__(self):
552544 return u'shell command "%s"' % self.command
545
546 def __eq__(self, other):
547 return self.__class__ == other.__class__ and self.command == other.command
553548
554549 def run(self, body=None, input=None):
555550 # expand variables in the command
5858 b.append(u'= Expected result here.')
5959 result = b.classify(ParseState(current_functionality=f))
6060 self.assertIsInstance(result, Test)
61 #self.assertEqual(result.body_block, None)
61 self.assertEqual(result.body_block.lines, [u'Test body here.'])
62 self.assertEqual(result.body_block.line_num, 1)
63 self.assertEqual(result.body_block.filename, None)
6264 self.assertEqual(result.input_block, None)
6365 self.assertEqual(result.expectation, OutputOutcome(u'Expected result here.'))
6466 self.assertEqual(result.functionality, f)
7375 b.append(u'? Expected error here.')
7476 result = b.classify(ParseState(current_functionality=f))
7577 self.assertIsInstance(result, Test)
76 #self.assertEqual(result.body_block, None)
78 self.assertEqual(result.body_block.lines, [u'Test body here.'])
79 self.assertEqual(result.body_block.line_num, 1)
80 self.assertEqual(result.body_block.filename, None)
7781 self.assertEqual(result.input_block, None)
7882 self.assertEqual(result.expectation, ErrorOutcome(u'Expected error here.'))
7983 self.assertEqual(result.functionality, f)
124128 d.append(u" | This is some test body.")
125129 d.append(u' = Expected result')
126130 functionalities = {}
127 self.assertEqual(
128 repr(d.extract_tests(functionalities)),
129 "[Test(body_block=Block(line_num=4), input_block=None, "
130 "expectation=OutputOutcome(u'Expected result'), "
131 "functionality=Functionality(u'Parse Thing'), "
132 "desc_block=InterveningText(line_num=1), "
133 "body=u'This is some test body.', input=None)]"
134 )
131 tests = d.extract_tests(functionalities)
132 self.assertEqual(len(tests), 1)
133 result = tests[0]
134 self.assertIsInstance(result, Test)
135 self.assertEqual(result.body_block.lines, [u'This is some test body.'])
136 self.assertEqual(result.body_block.line_num, 4)
137 self.assertEqual(result.body_block.filename, None)
138 self.assertEqual(result.input_block, None)
139 self.assertEqual(result.expectation, OutputOutcome(u'Expected result'))
140 self.assertEqual(result.functionality, functionalities['Parse Thing'])
141 self.assertEqual(result.desc_block.__class__, InterveningText)
142 self.assertEqual(result.desc_block.lines, [u'This is a test file.'])
143 self.assertEqual(result.body, u'This is some test body.')
144 self.assertEqual(result.input, None)
135145
136146 def test_extract_tests_more(self):
137147 d = Document()
160170 [u'This is some test body.\nIt extends over two lines.',
161171 u'Test with input', u'Test with input', u'Thing']
162172 )
163 #self.assertEqual(
164 # [t.input_block for t in tests],
165 # [None, Block(line_num=8), Block(line_num=12), None]
166 #)
167 self.assertEqual(
168 tests[1].input_block.text(),
169 u'input-for-test'
170 )
171 self.assertEqual(
172 tests[2].input_block.text(),
173 u'Other input-for-test'
173 self.assertEqual(
174 [t.input_block.__class__ for t in tests],
175 [None.__class__, Block, Block, None.__class__]
176 )
177 self.assertEqual(
178 [t.input_block.text() for t in tests if t.input_block is not None],
179 [u'input-for-test', u'Other input-for-test']
174180 )
175181 self.assertEqual(
176182 [t.expectation for t in tests],
239245 tests = d.extract_tests(funs)
240246 self.assertEqual(list(funs.keys()), ['Parse Stuff'])
241247 self.assertEqual(
242 [repr(i) for i in funs["Parse Stuff"].implementations],
243 ["ShellImplementation(u'parse')", "ShellImplementation(u'pxxxy')"]
248 [i for i in funs["Parse Stuff"].implementations],
249 [ShellImplementation(u'parse'), ShellImplementation(u'pxxxy')]
244250 )
245251
246252