| | 1393 | |
| | 1394 | def test_extract_py_def_directive_with_py_strip(self): |
| | 1395 | # Failed extraction from Trac |
| | 1396 | tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/" py:strip=""> |
| | 1397 | <py:def function="diff_options_fields(diff)"> |
| | 1398 | <label for="style">View differences</label> |
| | 1399 | <select id="style" name="style"> |
| | 1400 | <option selected="${diff.style == 'inline' or None}" |
| | 1401 | value="inline">inline</option> |
| | 1402 | <option selected="${diff.style == 'sidebyside' or None}" |
| | 1403 | value="sidebyside">side by side</option> |
| | 1404 | </select> |
| | 1405 | <div class="field"> |
| | 1406 | Show <input type="text" name="contextlines" id="contextlines" size="2" |
| | 1407 | maxlength="3" value="${diff.options.contextlines < 0 and 'all' or diff.options.contextlines}" /> |
| | 1408 | <label for="contextlines">lines around each change</label> |
| | 1409 | </div> |
| | 1410 | <fieldset id="ignore" py:with="options = diff.options"> |
| | 1411 | <legend>Ignore:</legend> |
| | 1412 | <div class="field"> |
| | 1413 | <input type="checkbox" id="ignoreblanklines" name="ignoreblanklines" |
| | 1414 | checked="${options.ignoreblanklines or None}" /> |
| | 1415 | <label for="ignoreblanklines">Blank lines</label> |
| | 1416 | </div> |
| | 1417 | <div class="field"> |
| | 1418 | <input type="checkbox" id="ignorecase" name="ignorecase" |
| | 1419 | checked="${options.ignorecase or None}" /> |
| | 1420 | <label for="ignorecase">Case changes</label> |
| | 1421 | </div> |
| | 1422 | <div class="field"> |
| | 1423 | <input type="checkbox" id="ignorewhitespace" name="ignorewhitespace" |
| | 1424 | checked="${options.ignorewhitespace or None}" /> |
| | 1425 | <label for="ignorewhitespace">White space changes</label> |
| | 1426 | </div> |
| | 1427 | </fieldset> |
| | 1428 | <div class="buttons"> |
| | 1429 | <input type="submit" name="update" value="${_('Update')}" /> |
| | 1430 | </div> |
| | 1431 | </py:def></html>""") |
| | 1432 | translator = Translator() |
| | 1433 | tmpl.add_directives(Translator.NAMESPACE, translator) |
| | 1434 | messages = list(translator.extract(tmpl.stream)) |
| | 1435 | self.assertEqual(10, len(messages)) |
| | 1436 | self.assertEqual([ |
| | 1437 | (3, None, u'View differences', []), |
| | 1438 | (6, None, u'inline', []), |
| | 1439 | (8, None, u'side by side', []), |
| | 1440 | (10, None, u'Show', []), |
| | 1441 | (13, None, u'lines around each change', []), |
| | 1442 | (16, None, u'Ignore:', []), |
| | 1443 | (20, None, u'Blank lines', []), |
| | 1444 | (25, None, u'Case changes',[]), |
| | 1445 | (30, None, u'White space changes', []), |
| | 1446 | (34, '_', u'Update', [])], messages) |