| 70 | |
| 71 | |
| 72 | def assert_attribute(element, name, value=None): |
| 73 | if not hasattr(element, name): |
| 74 | assert False, _("The element {} does not have the attribute {}").format(element, name) |
| 75 | if not value: |
| 76 | if getattr(element, name) is None: |
| 77 | assert False, _("The element {} does not have a value for the attribute {}").format(element, name) |
| 78 | return getattr(element, name) |
| 79 | if value == "NULL": |
| 80 | value = None |
| 81 | actual_value = getattr(element, name) |
| 82 | if isinstance(value, list) and actual_value: |
| 83 | actual_value = list(actual_value) |
| 84 | assert actual_value == value, _('We expected a value of "{}" but instead got "{}" for the element {}').format( |
| 85 | value, actual_value, element |
| 86 | ) |
| 87 | |
| 88 | |
| 89 | def assert_pset(element, pset_name, prop_name=None, value=None): |