[MRG+1] Remove all nose imports from test scripts.#422
[MRG+1] Remove all nose imports from test scripts.#422aabadie merged 9 commits intojoblib:masterfrom
Conversation
- These include assert_true, assert_false, assert_equal and assert_not_equal.
- Four more files in joblib/tests directory
68aafd8 to
7dffa56
Compare
|
Only one job of travis fails, I don't know why. I can't reproduce the error 😕 |
| assert_false = _dummy.assertFalse | ||
| assert_equal = _dummy.assertEqual | ||
| assert_not_equal = _dummy.assertNotEqual | ||
| with_setup = nose.tools.with_setup |
There was a problem hiding this comment.
Current framework is still dependent on nose, still its usage is only limited to joblib.testing module. Once this is done, we can easily move to pytest fixtures. I am not sure whether unittest module has something similar to with_setup.
|
@karandesai-96, thanks a lot for providing this PR. This is definitely something useful to prepare the switch to pytest. The travis error is indeed not related to your changes. There's an issue already opened about that #413. I restarted the build. |
aabadie
left a comment
There was a problem hiding this comment.
Except a few alignment issues and cosmit changes/nitpicks, the update in the test modules is ok.
I added comments in the testing module because there's something weird with the assert_raises import.
joblib/test/test_memory.py
Outdated
| current_accumulator = len(accumulator) | ||
| gg(1) | ||
| yield nose.tools.assert_equal, len(accumulator), \ | ||
| yield assert_equal, len(accumulator), \ |
There was a problem hiding this comment.
Splitting this line is now not required (see line 144 above)
joblib/test/test_func_inspect.py
Outdated
|
|
||
| def test_filter_args(): | ||
| yield nose.tools.assert_equal, filter_args(f, [], (1, )),\ | ||
| yield assert_equal, filter_args(f, [], (1, )),\ |
There was a problem hiding this comment.
Several of the lines below don't need to be splitted.
| nose.tools.assert_equal(warn.category, UserWarning) | ||
| nose.tools.assert_equal(warn.message.args[0], | ||
| assert_equal(warn.category, UserWarning) | ||
| assert_equal(warn.message.args[0], |
There was a problem hiding this comment.
other parameters alignment not updated
joblib/test/test_numpy_pickle.py
Outdated
| numpy_pickle.dump(a, filename, cache_size=cache_size) | ||
| expected_nb_warnings = 1 if cache_size is not None else 0 | ||
| nose.tools.assert_equal(len(caught_warnings), | ||
| assert_equal(len(caught_warnings), |
| nose.tools.assert_equal(warn.category, DeprecationWarning) | ||
| nose.tools.assert_equal(warn.message.args[0], | ||
| assert_equal(warn.category, DeprecationWarning) | ||
| assert_equal(warn.message.args[0], |
joblib/test/test_parallel.py
Outdated
| 10, | ||
| len(Parallel(n_jobs=2, backend=backend, timeout=10) | ||
| (delayed(sleep)(0.001) for x in range(10)))) | ||
| assert_equal(10, len(Parallel(n_jobs=2, backend=backend, timeout=10) |
There was a problem hiding this comment.
for readability, I would split the lines here: one for the expected value, one (well 2) for the tested expression.
joblib/testing.py
Outdated
| expected_exception(expected_regexp)) | ||
|
|
||
|
|
||
| try: |
There was a problem hiding this comment.
Is this required ? Joblib is already tested against python 2.6 and it doesn't need this.
There was a problem hiding this comment.
Maybe it should be a try on an import of assert_raises from unittest and if it fails (python 2.6), import assert_raises from nose.tools ?
There was a problem hiding this comment.
just had a look at scikit-learn (who did the same recently) and there's nothing of this kind, just
from nose.tools import assert_raises
joblib/test/test_parallel.py
Outdated
| # Check that timeout properly fails when function is too slow | ||
| for backend in ['multiprocessing', 'threading']: | ||
| nose.tools.assert_raises( | ||
| assert_raises( |
There was a problem hiding this comment.
For readability, I would move TimeuotError on the same line and update the other lines alignment.
|
I'll address your changes but I was wondering this while making the changes: callable_obj(long_arg1,
long_arg2,
**long_kwargs)and I want to change the name "callable_obj" - it changes its length and 3 lines have to be changed manually. ( I faced this while doing While here only one line changes: callable_obj(
long_arg1,
long_arg2,
**long_kwargs
)Too much to change across the codebase so I won't break the uniformity in this PR but this can be thought upon. |
|
To me number of lines changed is less important than the whole related code statement readability and style consistency. nose.tools.assert_equal(long_param1,
long_param2)should become: |
|
assert_true(param1,
param2)
IMHO, PEP8 tells us that this should be written on one line, as it is
well below 79 characters. The line returns are added for lines that are
long.
|
|
@GaelVaroquaux, indeed but this was just for the example. |
|
comment updated |
6c9fdfa to
c2c3498
Compare
- joblib is compatible with python 2.6+ and 3.3+ it need not handle exceptional cases if version is less than 2.6
2cba539 to
c73bad0
Compare
|
@aabadie I have addressed your review comments, and all CI services are happy now 💚 The spread out usage of If there is anything left to add / modify in this PR, I'm here, thanks. |
eeb5afd to
07dd20c
Compare
|
@karandesai-96, I allow myself to push a small update on top of your recent changes (this is a new feature with GitHub). Hope this is fine. By the way, thanks for updating the PR that fast ! LGTM, +1 for merge. |
|
@aabadie Sure, fine with me! Github did a nice thing adding this feature 😄 |
|
Looks good, small nitpick still some nose imports in doc fixtures, excerpt from I guess you can replace that by |
My 2cents: when doing project-wide search and replace that breaks PEP8 similar to yours, I found running autopep8 may help. Obviously if your project has a lot of other PEP8 violations it is not going to help much because you'll need to undo a lot of things after the autopep8. |
|
We are good now, merging. Thanks @karandesai-96 and @lesteve ! |
|
Great! Thank you everyone.
|
* commit '0.10.2-55-g660fe5d': (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...
* releases: (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...
Starter PR on #411
To initiate the migration form nose to py.test, this PR first of all removes all the direct usages of "nose" in all test scripts. It wraps the following utilities of nose / unittest modules in joblib/testing.py
assert_true,assert_falseassert_equal,assert_not_equalassert_raiseswith_setup,SkipTestAll the imports in scripts housed under directory joblib/tests such as:
have been replaced in a uniform fashion:
joblib.testingjoblib.testingis imported asfrom x import y, zThis can ease up the migration and is the first PR iniiating the process.