Solution — Brownie testing for reverted transactions does not work with pytest.raises() or brownie.reverts() on Python 3.10.2
The problem
When we are trying to test for a reverted transaction to make sure the “only owner” modifier works as intended. The check relies on a mechanism where a Virtualmachine error is caught when the transaction reverts and thus proves, that the modifier works.
Until brownie v1.18.1 this mechanism won’t work, throws an error, and interrupts the test, see my bug request in the eth-brownie repository here:
eth-brownie/brownie#1441
However, the current Python 3.10.2 will only install Brownie version v1.16.4 and any efforts to force the new version on it will result in another error.
The solution
The only (for me) acceptable solution is to set up a virtual environment with a specific Python version, in my case 3.9.10, which will install the newest brownie version.
This process is described in this post here:
https://n4n0b1t3.medium.com/how-to-use-a-different-python-version-in-a-virtual-environment-to-solve-version-compatibility-79afd5c15038
In order to test if your setup has the same issue, you can download the test sources here:
https://github.com/n4n0b1t3/brownie.reverts.example