Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Use context manager for assertRaises #536

Closed
pferate opened this issue Jun 30, 2016 · 3 comments
Closed

Use context manager for assertRaises #536

pferate opened this issue Jun 30, 2016 · 3 comments

Comments

@pferate
Copy link
Contributor

pferate commented Jun 30, 2016

In the unit tests, update the assertRaises calls to use the context manager.

self.assertRaises(SomeException, do_something, arg1)

change to:

with self.assertRaises(SomeException):
    do_something(arg1)
@pferate
Copy link
Contributor Author

pferate commented Jun 30, 2016

According to the Python docs, this was added in 2.7.

There are some tests that are already using this syntax, so I'm curious to see what's going on there that doesn't have them fail in py26. I will look into this later.

If this is incompatible with 2.6, then this may need to wait until 2.6 support is dropped in September.

@theacodes
Copy link
Contributor

unittest2 probably fixes compatibility.

@pferate
Copy link
Contributor Author

pferate commented Jul 1, 2016

Ahhh, that looks like it. Thanks. It will probably be next week before I
could work on it.

On Thu, Jun 30, 2016, 2:46 PM Jon Wayne Parrott notifications@github.com
wrote:

unittest2 probably fixes compatibility.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#536 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAckK8ff5ZNux-4N2vNdlKRBHGv4lPROks5qRDfCgaJpZM4JCm4O
.

pferate added a commit to pferate/oauth2client that referenced this issue Jul 5, 2016
pferate added a commit to pferate/oauth2client that referenced this issue Jul 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants