|
| 1 | +import pytest |
| 2 | + |
| 3 | +from evmspec.data._ids import ChainId, TransactionIndex, LogIndex |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 7 | +def test_add(cls): |
| 8 | + with pytest.raises(TypeError) as exc_info: |
| 9 | + cls(1) + 1 |
| 10 | + e = exc_info.value |
| 11 | + assert ( |
| 12 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 13 | + ) |
| 14 | + |
| 15 | + |
| 16 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 17 | +def test_sub(cls): |
| 18 | + with pytest.raises(TypeError) as exc_info: |
| 19 | + cls(1) - 1 |
| 20 | + e = exc_info.value |
| 21 | + assert ( |
| 22 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 23 | + ) |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 27 | +def test_mul(cls): |
| 28 | + with pytest.raises(TypeError) as exc_info: |
| 29 | + cls(1) * 1 |
| 30 | + e = exc_info.value |
| 31 | + assert ( |
| 32 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 33 | + ) |
| 34 | + |
| 35 | + |
| 36 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 37 | +def test_truediv(cls): |
| 38 | + with pytest.raises(TypeError) as exc_info: |
| 39 | + cls(1) / 1 |
| 40 | + e = exc_info.value |
| 41 | + assert ( |
| 42 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 47 | +def test_floordiv(cls): |
| 48 | + with pytest.raises(TypeError) as exc_info: |
| 49 | + cls(1) // 1 |
| 50 | + e = exc_info.value |
| 51 | + assert ( |
| 52 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 53 | + ) |
| 54 | + |
| 55 | + |
| 56 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 57 | +def test_pow(cls): |
| 58 | + with pytest.raises(TypeError) as exc_info: |
| 59 | + cls(1) ** 1 |
| 60 | + e = exc_info.value |
| 61 | + assert ( |
| 62 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 63 | + ) |
| 64 | + |
| 65 | + |
| 66 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 67 | +def test_radd(cls): |
| 68 | + with pytest.raises(TypeError) as exc_info: |
| 69 | + 1 + cls(1) |
| 70 | + e = exc_info.value |
| 71 | + assert ( |
| 72 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 73 | + ) |
| 74 | + |
| 75 | + |
| 76 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 77 | +def test_rsub(cls): |
| 78 | + with pytest.raises(TypeError) as exc_info: |
| 79 | + 1 - cls(1) |
| 80 | + e = exc_info.value |
| 81 | + assert ( |
| 82 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 87 | +def test_rmul(cls): |
| 88 | + with pytest.raises(TypeError) as exc_info: |
| 89 | + 1 * cls(1) |
| 90 | + e = exc_info.value |
| 91 | + assert ( |
| 92 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 93 | + ) |
| 94 | + |
| 95 | + |
| 96 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 97 | +def test_rtruediv(cls): |
| 98 | + with pytest.raises(TypeError) as exc_info: |
| 99 | + 1 / cls(1) |
| 100 | + e = exc_info.value |
| 101 | + assert ( |
| 102 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 103 | + ) |
| 104 | + |
| 105 | + |
| 106 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 107 | +def test_rfloordiv(cls): |
| 108 | + with pytest.raises(TypeError) as exc_info: |
| 109 | + 1 // cls(1) |
| 110 | + e = exc_info.value |
| 111 | + assert ( |
| 112 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 113 | + ) |
| 114 | + |
| 115 | + |
| 116 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 117 | +def test_rpow(cls): |
| 118 | + with pytest.raises(TypeError) as exc_info: |
| 119 | + 1 ** cls(1) |
| 120 | + e = exc_info.value |
| 121 | + assert ( |
| 122 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 123 | + ) |
| 124 | + |
| 125 | + |
| 126 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 127 | +def test_iadd(cls): |
| 128 | + obj = cls(1) |
| 129 | + with pytest.raises(TypeError) as exc_info: |
| 130 | + obj += 1 |
| 131 | + e = exc_info.value |
| 132 | + assert ( |
| 133 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 134 | + ) |
| 135 | + |
| 136 | + |
| 137 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 138 | +def test_isub(cls): |
| 139 | + obj = cls(1) |
| 140 | + with pytest.raises(TypeError) as exc_info: |
| 141 | + obj -= 1 |
| 142 | + e = exc_info.value |
| 143 | + assert ( |
| 144 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 145 | + ) |
| 146 | + |
| 147 | + |
| 148 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 149 | +def test_imul(cls): |
| 150 | + obj = cls(1) |
| 151 | + with pytest.raises(TypeError) as exc_info: |
| 152 | + obj *= 1 |
| 153 | + e = exc_info.value |
| 154 | + assert ( |
| 155 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 156 | + ) |
| 157 | + |
| 158 | + |
| 159 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 160 | +def test_itruediv(cls): |
| 161 | + obj = cls(1) |
| 162 | + with pytest.raises(TypeError) as exc_info: |
| 163 | + obj /= 1 |
| 164 | + e = exc_info.value |
| 165 | + assert ( |
| 166 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 167 | + ) |
| 168 | + |
| 169 | + |
| 170 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 171 | +def test_ifloordiv(cls): |
| 172 | + obj = cls(1) |
| 173 | + with pytest.raises(TypeError) as exc_info: |
| 174 | + obj //= 1 |
| 175 | + e = exc_info.value |
| 176 | + assert ( |
| 177 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 178 | + ) |
| 179 | + |
| 180 | + |
| 181 | +@pytest.mark.parametrize("cls", (ChainId, TransactionIndex, LogIndex)) |
| 182 | +def test_ipow(cls): |
| 183 | + obj = cls(1) |
| 184 | + with pytest.raises(TypeError) as exc_info: |
| 185 | + obj **= 1 |
| 186 | + e = exc_info.value |
| 187 | + assert ( |
| 188 | + len(e.args) == 1 and e.args[0] == f"You cannot perform math on a {cls.__name__}" |
| 189 | + ) |
0 commit comments