launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31643
Re: [Merge] ~ines-almeida/launchpad:fix-supported-arches-error-message into launchpad:master
Launchpad's test setup is using a set of arcane and weird test tools, but it is very much possible to do what we want without too much effort.
`assertRaises` comes not from the standard unittest framework, but from `testtools`. And while they claim they `Improved assertRaises`, actually they limited it in a very bad way. You cannot pass in the `msg` param for the exception message any more.
In order to "unimprove" `assertRaises` the former Launchpad engineers created the `assertRaisesWithContent` method, which just accepts the expected exception message again.
While looking around, I saw that we also use this paradigm to test exception messages.
```python
self.assertThat(
build_instances_factory, Raises(self.expected_exception)
)
```
And in the list of scenarios as they are called here, you can write something like this
```python
"expected_exception": MatchesException(
DuplicateRunOnError,
r"ubuntu 20\.04 \[\"amd64\"\] is present in the 'run-on' "
r"of multiple items",
),
```
Testing exception messages has more benefits that it seems.
There can be runtime issues when creating the exception message and you can check whether the exception messages make sense.
One of the current exception messages is like..
```
"amd64 is present in the 'build-on' of multiple items"
```
which sounds really strange to me.
--
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/474468
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:fix-supported-arches-error-message into launchpad:master.
References