Instead of simulating an Exception in the unit test, obfuscate_fields can be passed an input, that will cause it to raise an Exception. Ideally, inputs that are known to raise an Exception should be handled individually, however, is we pass anException as an argument, this should always reproduce a generic Exception which has not been handled.
Issue
Generic Exceptions in
obfuscate_fields
are raised as anObfuscationError
:However, this line is not covered by the unit test written for it, which only checks that a generic
Exception
was raised:Updating the test to check an ObfuscationError is raised causes the test to fail:
Proposed resolution
Instead of simulating an
Exception
in the unit test,obfuscate_fields
can be passed an input, that will cause it to raise an Exception. Ideally, inputs that are known to raise anException
should be handled individually, however, is we pass anException
as an argument, this should always reproduce a genericException
which has not been handled.