cubicweb #2276662 Improve self.login and self.assertRaises CM interaction in test cases [open]
In CubicWebTC the context managers returned by self.login and self.assertRaises do not play well (or at least intuitively) with each other. We would like to write
with self.login(user) as cur: ... with self.assertRaises(...) as cm: ... self.assertXXX( cm.exception, ...) .... # other tests
But we can't because the expected exception will let the connection in the uncommitable state, which will raise a QueryError('connection needs to be rollbacked'). A solution is to add a `self.rollback() just before the other tests.
This is no bug but a very common error in writting tests. We propose to enhance the self.login CM to issue a specific message in this case.
|done in||<not specified>|
|closed by||<not specified>|