| | 1337 | |
| | 1338 | |
| | 1339 | |
| | 1340 | def test_extract_py_def_directive(self): |
| | 1341 | # Failed extraction from Trac |
| | 1342 | tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> |
| | 1343 | <py:def function="diff_options_fields(diff)"> |
| | 1344 | <label for="style">View differences</label> |
| | 1345 | <select id="style" name="style"> |
| | 1346 | <option selected="${diff.style == 'inline' or None}" |
| | 1347 | value="inline">inline</option> |
| | 1348 | <option selected="${diff.style == 'sidebyside' or None}" |
| | 1349 | value="sidebyside">side by side</option> |
| | 1350 | </select> |
| | 1351 | <div class="field"> |
| | 1352 | Show <input type="text" name="contextlines" id="contextlines" size="2" |
| | 1353 | maxlength="3" value="${diff.options.contextlines < 0 and 'all' or diff.options.contextlines}" /> |
| | 1354 | <label for="contextlines">lines around each change</label> |
| | 1355 | </div> |
| | 1356 | <fieldset id="ignore" py:with="options = diff.options"> |
| | 1357 | <legend>Ignore:</legend> |
| | 1358 | <div class="field"> |
| | 1359 | <input type="checkbox" id="ignoreblanklines" name="ignoreblanklines" |
| | 1360 | checked="${options.ignoreblanklines or None}" /> |
| | 1361 | <label for="ignoreblanklines">Blank lines</label> |
| | 1362 | </div> |
| | 1363 | <div class="field"> |
| | 1364 | <input type="checkbox" id="ignorecase" name="ignorecase" |
| | 1365 | checked="${options.ignorecase or None}" /> |
| | 1366 | <label for="ignorecase">Case changes</label> |
| | 1367 | </div> |
| | 1368 | <div class="field"> |
| | 1369 | <input type="checkbox" id="ignorewhitespace" name="ignorewhitespace" |
| | 1370 | checked="${options.ignorewhitespace or None}" /> |
| | 1371 | <label for="ignorewhitespace">White space changes</label> |
| | 1372 | </div> |
| | 1373 | </fieldset> |
| | 1374 | <div class="buttons"> |
| | 1375 | <input type="submit" name="update" value="${_('Update')}" /> |
| | 1376 | </div> |
| | 1377 | </py:def></html>""") |
| | 1378 | translator = Translator() |
| | 1379 | tmpl.add_directives(Translator.NAMESPACE, translator) |
| | 1380 | messages = list(translator.extract(tmpl.stream)) |
| | 1381 | self.assertEqual(10, len(messages)) |
| | 1382 | self.assertEqual([ |
| | 1383 | (3, None, u'View differences', []), |
| | 1384 | (6, None, u'inline', []), |
| | 1385 | (8, None, u'side by side', []), |
| | 1386 | (10, None, u'Show', []), |
| | 1387 | (13, None, u'lines around each change', []), |
| | 1388 | (16, None, u'Ignore:', []), |
| | 1389 | (20, None, u'Blank lines', []), |
| | 1390 | (25, None, u'Case changes',[]), |
| | 1391 | (30, None, u'White space changes', []), |
| | 1392 | (34, '_', u'Update', [])], messages) |