| 42 | |
| 43 | |
| 44 | def test_format_variety(): |
| 45 | def _(fmt, matches): |
| 46 | d = parse.extract_format(fmt, {"spam": "spam"}) |
| 47 | for k in matches: |
| 48 | assert d.get(k) == matches[k] |
| 49 | |
| 50 | for t in "%obxegfdDwWsS": |
| 51 | _(t, {"type": t}) |
| 52 | _("10" + t, {"type": t, "width": "10"}) |
| 53 | _("05d", {"type": "d", "width": "5", "zero": True}) |
| 54 | _("<", {"align": "<"}) |
| 55 | _(".<", {"align": "<", "fill": "."}) |
| 56 | _(">", {"align": ">"}) |
| 57 | _(".>", {"align": ">", "fill": "."}) |
| 58 | _("^", {"align": "^"}) |
| 59 | _(".^", {"align": "^", "fill": "."}) |
| 60 | _("x=d", {"type": "d", "align": "=", "fill": "x"}) |
| 61 | _("d", {"type": "d"}) |
| 62 | _("ti", {"type": "ti"}) |
| 63 | _("spam", {"type": "spam"}) |
| 64 | |
| 65 | _(".^010d", {"type": "d", "width": "10", "align": "^", "fill": ".", "zero": True}) |
| 66 | _(".2f", {"type": "f", "precision": "2"}) |
| 67 | _("10.2f", {"type": "f", "width": "10", "precision": "2"}) |
| 68 | |
| 69 | |
| 70 | def test_dot_separated_fields(): |