Skip to content
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

Nose cleanup first step #13206

Merged
merged 48 commits into from
Oct 26, 2021
Merged

Nose cleanup first step #13206

merged 48 commits into from
Oct 26, 2021

Conversation

sgaist
Copy link
Contributor

@sgaist sgaist commented Oct 20, 2021

This merge request goes through the test files and makes a first pass cleanup to remove the direct use of nose in the test files themselves.

Each file has been cleaned up independently so that it can be reviewed in an easy fashion.

Part of #13108

Copy link
Member

@Carreau Carreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments, I think you forgot one assert.

I'm also trying to see if it's possible to rebase and and applying the reformat hook to each commit, so that it does not complain in the test suite. If that works i'll point you to the rebased branch and the reformat commit, and we can decide if we ant to squash them or not.

Feel free to also do many smaller PRs, that might allow me to quickly review them and merge when I'm in between two compilations or waiting on another test suite.

, to see if I can get the test to pass, and

@@ -329,16 +326,16 @@ def test_no_ascii_back_completion(self):
# single ascii letter that don't have yet completions
for letter in "jJ":
name, matches = ip.complete("\\" + letter)
nt.assert_equal(matches, [])
self.assertEqual(matches, [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's always skipped we might as well delete the test ?
Can be done in separately, just taking notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

I think that a separate step is better to keep things clear.

IPython/core/tests/test_display.py Outdated Show resolved Hide resolved
nt.assert_raises(ValueError, display.Image)
nt.assert_raises(ValueError, display.Image, data='this is not an image', format='badformat', embed=True)
pytest.raises(ValueError, display.Image)
pytest.raises(ValueError, display.Image, data='this is not an image', format='badformat', embed=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I wasn't aware you could use pytest raises like so.

IPython/core/tests/test_display.py Outdated Show resolved Hide resolved

def test_cellmagic_help(self):
self.sp.push('%%cellm?')
nt.assert_false(self.sp.push_accepts_more())
assert not self.sp.push_accepts_more()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Philosophical question, is nt.assert_false equivalent to that, or equivalent to is false, because:

>>> not ''
True

? I think that's fine here, but just leaving my own questioning here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's the same for assert vs assert_true...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You raise a good point.

Being more explicit with is false and is true will also makes the expected output of the method clearer. I'll update the checks.

from matplotlib import pyplot as plt
import matplotlib_inline
from matplotlib_inline import backend_inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you meant to do some more refactor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, on my machine, if backend_inline is not explicitly imported, I get AttributeError: module 'matplotlib_inline' has no attribute 'backend_inline'.

It might be because I installed matplotlib through conda rather than pip.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinRenou ? Want to add ad from . import backend_inline in __init__.py ?

IPython/core/tests/test_splitinput.py Outdated Show resolved Hide resolved
@Carreau
Copy link
Member

Carreau commented Oct 21, 2021

I want to make sure @Kojoley sees that and does not do too much of duplicate work.

My computer is still rebasing and applying the auto formatter, Will post updates when it's finished.

@Carreau
Copy link
Member

Carreau commented Oct 21, 2021

You can check this branch https://github.com/Carreau/ipython/tree/nose_cleanup_first_step, it is the same as your except every-other commit run the reformat step.

If you want I can either push it as it, or squash every other commits to be part of what you did, and I can also push to your branch. Let me know if you want me to do that.

@Kojoley
Copy link
Collaborator

Kojoley commented Oct 21, 2021

On this kind of changes it is useful to check code coverage for regressions. I see that CI is uploading coverage to codecov https://codecov.io/github/ipython/ipython/commit/fdee94ec9e877777cd30beccb1b42e744fb42d10 but no info is added to the PR status, is it intentionally?

@Carreau
Copy link
Member

Carreau commented Oct 21, 2021

is it intentionally?

I don't quite remember, I believe that when we originally added codecov the bot was poting a new comment on each push/each time a new CI item would finish. I don't believe it's the case anymore so we can re-enable. I'll see if I can do
that.

Sidenote, there is a conflict now.

@Kojoley
Copy link
Collaborator

Kojoley commented Oct 21, 2021

I don't quite remember, I believe that when we originally added codecov the bot was poting a new comment on each push/each time a new CI item would finish.

Yeah, that bot could be quite annoying, but it is not required for the status updates through API that just adds a line with code coverage stats in PR "checks" status box.

@Carreau
Copy link
Member

Carreau commented Oct 21, 2021

I'm not quite sure why the status is not posted.

I'm going to try things in #13207

@sgaist
Copy link
Contributor Author

sgaist commented Oct 21, 2021

With regard to darker, what about introducing pre-commit hooks to the repository ?

@Carreau
Copy link
Member

Carreau commented Oct 22, 2021

With regard to darker, what about introducing pre-commit hooks to the repository ?

I think it would be ok to add. I have it personally as an editor hook so I don't need a pre-commit hook.

But I'm also a bit worried it is as disruptive for users, in another project I work on, the pre-commit hook takes 5 sec, and every other time prevent me from committing even if I know i don't care about having all the files formatted, and no unused variables.

So I'd be happy to have one, but I don't want to enforce it if it disturb user.

in this particular PR, as you seem to be fairly familiar with git and it touched a bunch of files, I pushed to have each commit properly formatted, but on a new contributor, and smaller PRS I would have just pushed a single formatting commit before merging.

@sgaist
Copy link
Contributor Author

sgaist commented Oct 23, 2021

I am all for properly formatted code. As matter of fact I wanted to ask about doing a round of black/isort run once the move to pytest was done.

For pre-commit hooks, there's nothing to worry about for newcomers. If you don't run pre-commit install they won't be called at all.

However, I think that encouraging them to use it will also help them learn the tool which is beneficial.

@sgaist sgaist requested a review from Carreau October 23, 2021 12:07
@sgaist
Copy link
Contributor Author

sgaist commented Oct 23, 2021

I think there might be some issue with code coverage as it looks like Windows is not taken into account and there are quite a lot of tests that are skipped of it.

@Carreau Carreau added this to the 8.0 milestone Oct 25, 2021
@Carreau
Copy link
Member

Carreau commented Oct 25, 2021

I think there might be some issue with code coverage as it looks like Windows is not taken into account and there are quite a lot of tests that are skipped of it.

Don't worry about github and coverage for now unless there is a delta which is gigantic.
There is a lot of code for weird corner case that don't get covered and might not be necessary.

rev: 1.3.1
hooks:
- id: darker

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 awesome.

from matplotlib import pyplot as plt
import matplotlib_inline
from matplotlib_inline import backend_inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinRenou ? Want to add ad from . import backend_inline in __init__.py ?

@Carreau
Copy link
Member

Carreau commented Oct 26, 2021

Ok, let's get that in.

@Carreau Carreau merged commit 24290cb into ipython:master Oct 26, 2021
@Carreau
Copy link
Member

Carreau commented Oct 26, 2021

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants