Skip to content

New style guidelines: should we ban the usage of assertRaises in testing? #1660

@MVrachev

Description

@MVrachev

Description of issue or feature request:

Currently our code style guidelines doesn't specify anything about the usage of self.assertRaises vs the usage of with self.assertRaises():

Using self.assertRaises can lead to long statements separated to multiline expressions as pointed out by @jku here: #1658 (comment).
On another hand with self.assertRaises(): looks better in my opinion:

with self.assertRaises(DeserializationError):

Long expressions look a lot better
with self.assertRaises(exceptions.UnsignedMetadataError):
when using with self.assertRaises(): than using self.assertRaises(): as pointed out in Jussi's comment.

Current behavior:

No guidelines about self.assertRaises vs with self.assertRaises():.

Expected behavior:

The question is should we specify something more concrete?

EDIT: We decided we would remove all instances of self.assertRaises and replace them with with self.assertRaises.

Metadata

Metadata

Assignees

Labels

backlogIssues to address with priority for current development goalsdiscussionDiscussions related to the design, implementation and operation of the projecttesting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions