Use unittest-style tests#440
Conversation
|
Generally looks good. A couple of minor questions, and the major issue that it isn't actually running any tests in CI right now. |
|
@corranwebster Tests pass (and are actually running this time). I think I've addressed your comments, would you like to give this another look? |
|
Actually, I marked one test as an |
|
@corranwebster I've fixed up the issue with the expected failure, and I think this is good to go. Would you mind giving this a last look? |
| tool = RangeSelection(renderer) | ||
| with warnings.catch_warnings(record=True) as w: | ||
| # Ignore warnings coming from Traits | ||
| warnings.filterwarnings( |
There was a problem hiding this comment.
Being a bit picky here, but I think this is changing the global state of the warning filters but not resetting it, and so could affect the outcome of other tests which mess with warnings. Unfortunately this looks awkward to do in the warnings module withot messing with warnings.filter directly.
There was a problem hiding this comment.
I don't think this is an issue here, since it's wrapped in a catch_warnings block which will reset the filters upon exit:
In [1]: import warnings
In [2]: print(warnings.filters)
[('default', re.compile('', re.IGNORECASE), <class 'DeprecationWarning'>, re.compile('__main__'), 0), ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0)]
In [3]: with warnings.catch_warnings(record=True) as w:
...: warnings.filterwarnings("ignore", 'elementwise == comparison failed')
...: print(warnings.filters)
...:
[('ignore', re.compile('elementwise == comparison failed', re.IGNORECASE), <class 'Warning'>, re.compile(''), 0), ('default', re.compile('', re.IGNORECASE), <class 'DeprecationWarning'>, re.compile('__main__'), 0), ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0)]
In [4]: print(warnings.filters)
[('default', re.compile('', re.IGNORECASE), <class 'DeprecationWarning'>, re.compile('__main__'), 0), ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0)]There was a problem hiding this comment.
Cool, I didn't realise that.
|
Thanks @corranwebster ! |
fixes #439
The first few commits are concerned with turning nose-style tests into unittest test cases (this was done in a semi-automatic way, with lots of Emacs macros). The remaining commits do the following:
test_so that it can be picked up by the unittest discovery runnerAlong the way, I did some minor cleanup (removing unused print statements, rewriting overly complicated
sixconstructs, etc). I also made it so that the backend tests are run as part of the test suite: now that PyQt is easily installed, there is no need to keep these tests separate.