diff --git a/b2sdk/v2/exception.py b/b2sdk/v2/exception.py index 359af31c1..fad9437ea 100644 --- a/b2sdk/v2/exception.py +++ b/b2sdk/v2/exception.py @@ -23,4 +23,4 @@ def __init__(self, bucket_id): self.code = 'bad_bucket_id' def __str__(self): - return super(BadRequest, self).__str__() + return BadRequest.__str__(self) diff --git a/changelog.d/+fix_str_of_v2_BucketIdNotFound.fixed.md b/changelog.d/+fix_str_of_v2_BucketIdNotFound.fixed.md new file mode 100644 index 000000000..38ccd2da0 --- /dev/null +++ b/changelog.d/+fix_str_of_v2_BucketIdNotFound.fixed.md @@ -0,0 +1 @@ +Fix `__str__` of `b2sdk.v2.BucketIdNotFound` to return full error message and not just missing bucket ID value. diff --git a/test/unit/b2http/test_b2http.py b/test/unit/b2http/test_b2http.py index 9d5bff5f5..f8f7602c8 100644 --- a/test/unit/b2http/test_b2http.py +++ b/test/unit/b2http/test_b2http.py @@ -139,9 +139,11 @@ def test_bucket_id_not_found(self): def fcn(): raise v3BucketIdNotFound('bucket_id') - with pytest.raises(BucketIdNotFound): + with pytest.raises(BucketIdNotFound) as exc_info: B2Http._translate_errors(fcn) + assert str(exc_info.value) == 'Bucket with id=bucket_id not found (bad_bucket_id)' + def test_b2_error__nginx_html(): """