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

[testing] Remove nose usage #870

Merged
merged 2 commits into from
Apr 9, 2019
Merged

[testing] Remove nose usage #870

merged 2 commits into from
Apr 9, 2019

Conversation

jd
Copy link
Contributor

@jd jd commented Apr 2, 2019

This has been deprecated and unmaintained for years; stop installing it.

  • Replaces nose.tools.ok_ with assert
  • Replaces nose.tools.eq_ with assert ==
  • Replaces nose.tools.assert_raises with pytest.raises
  • Add missing unittest.TestCase inheritance in some place
  • Only install requests-mock for requests_contrib scenarios; this modules has a pytest plugin that gets loaded otherwise and pre-load
  • requests, making some test checking for module load ordering fail.

@jd jd requested a review from a team as a code owner April 2, 2019 21:58
@jd jd force-pushed the remove-nose branch 5 times, most recently from 5f7ef99 to bcffd0a Compare April 3, 2019 17:05
Copy link
Contributor

@majorgreys majorgreys left a comment

Choose a reason for hiding this comment

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

The one big suggestion I would have here is that we follow use the unittest.TestCase.assert* methods for any test cases we have already moved to using BaseTracerTestCase. That might be a separate PR from this one that removes the dependency to nose though.

What do you think?

PS RIP nose

@jd
Copy link
Contributor Author

jd commented Apr 4, 2019

I'd rather suggest to go full pytest and drop (in the long run) unittest usage.

There's no upside of using unittest if you're using pytest here.

And some other things listed here.

This has been deprecated and unmaintained for years; stop installing it.

- Replaces `nose.tools.ok_` with `assert`
- Replaces `nose.tools.eq_` with `assert ==`
- Replaces `nose.tools.assert_raises` with `pytest.raises`
- Add missing unittest.TestCase inheritance in some place
- Only install requests-mock for requests_contrib scenarios;
  this modules has a pytest plugin that gets loaded otherwise and pre-load
- `requests`, making some test checking for module load ordering fail.
@brettlangdon
Copy link
Member

I'd actually prefer to use base unittest methods over methods/fixtures from pytest, that way we keep pytest as a test runner only so it is easier to swap out in the future if we want (like what happened with nose).

Happy to discuss further if everyone feels that is a silly stance.

@jd
Copy link
Contributor Author

jd commented Apr 8, 2019

I guess there are two different things here, the runner and the test framework.

The thing is that — at least in the case of pytest — they are a bit tangled, making it weird to use unittest+pytest, which is actually more considered as a "compatibility mode" from pytest PoV.

That's the main reason that would make me lean towards going full pytest rather than staying in a "compat" world.

Considering pytest usage nowadays, I don't think the trade-off of staying in "unittest+pytest-compat-mode-in-case-the-world-switch-away-from-pytest" rather than the perks of going full pytest is worth it. :)

@brettlangdon
Copy link
Member

@jd fair enough. I've always had issues using some pytest features, but I've always tried to mix directly with unittest, probably why I had issues.

I don't have that strong of an opinion here, was just going simple (hell, should we just go with unitest + python -m unittest discover ? :p), if you and @majorgreys agree to go all in on pytest, then that is fine by me.

Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

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

really hoping you mostly just used sed here and didn't manually update all of these? 0_o

But otherwise, this lgtm.

@jd
Copy link
Contributor Author

jd commented Apr 9, 2019

I don't know about that sed tool you're talking about. It took me two entire nights to update this, but it was worth it. I'm a software craftsman and I believe in doing things by hand so I can feel the code.

jk, yeah I used sed. 🤣

@jd jd merged commit a304be5 into DataDog:0.24-dev Apr 9, 2019
@jd jd deleted the remove-nose branch April 9, 2019 16:58
@majorgreys majorgreys added this to the 0.24.0 milestone Apr 11, 2019
@majorgreys majorgreys mentioned this pull request Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants