New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests deprecation warnings in a backward compatible way #133
Fix tests deprecation warnings in a backward compatible way #133
Conversation
Sorry. I meant, please use a context manager with syntax like:
for all those assertRaises* calls. |
Do you mean the new ones added by this change or also existing ones a well ? |
I think all existing ones already use context manager. |
9d572e2
to
510b86f
Compare
Fixed the assertRaises calls to use context manager. The only thing left is modifying the class hierarchy to deal with the versioning problem. Btw I've updated fslabeling.py to the new syntax and LoopBackedTestCase to inherit from BlivetTestCase but for some reason I'm still getting these two errors
I can't figure out why this happens, all other classes which were modified to inherit from BlivetTestCase seem to work pretty well. |
Instead of changing the class hierarchy, could try importing unittest and assigning to TestCase methods in |
510b86f
to
7dc39e6
Compare
Thanks, I didn't actually think this will work but it did. It also fixed the labeling_test errors above. |
ok. this looks fine to me. |
I just realized there is another consideration. I think we should put a copy of that init.py file in every subdirectory of the test directory as well as at the top level. The reason for this is that you might want to run your unittests more selectively, like only those from a subdirectory of tests. In that case, the top level I believe that putting that |
@mulkieran - I've removed the shebang in PR #132 so we should be fine. Not sure if you'd like to document this change for anyone who wants to run the tests more selectively. (I'm not even sure if we'd like to encourage this practice) |
Thanks! Could you rebase and change the commit message to something more like this:
Then I should be able to push right away. |
Use assertion methods that are defined in Python 2 and not deprecated in Python 3 wherever possible. Where the only choice is between a method name that is deprecated in Python 3 and one that does not exist in Python 2, use the one that does not exist in Python 2, but translate it to the Python 2 equivalent when executing under Python 2.
7dc39e6
to
05e77a6
Compare
should be good to go |
Fix tests deprecation warnings in a backward compatible way
From the original review in PR #120
@mulkieran
This doesn't work b/c assertRaises and assertRaisesRegex are different. I'm not quite sure what do you mean but directly changing one for the other doesn't seem to work.
Fixed.
Let me see how can I do this. Is there a place where I can hook into before the test cases are actually executed? If so I can monkey-patch unittest.TestCase instead of creating another base class.