-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Move tests out of package to top level directory #1232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a reason why I included tests in psutil namespace and source distribution: the ability to test psutil installation with "python -m psutil.tests" without having to git clone the repo.
Hmm, I understand. FYI, the tests are also included in the source distribution, so a git clone isn't necessary if the package is already downloaded. As a user of the package, I consider it unwanted pollution of my The tests are for development of the package, not for using it. Should I want to test the psutil package or develop it, I can continue to use the source distribution or a git clone of the project. But the tests aren't necessary for my installed production environment. Most of the packages I interact with do not install their tests to Ultimately, up to you. Just making a suggestion as a user. Thanks for the great package! |
I came across the following articles which I thought you might find interesting. They outline why a project may prefer a "tests outside application code" approach.
The end of the 2nd article has the summary:
|
I rebased to resolve merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, you convinced me. Mainly I think removing tests from site-packages dir is the big win here so I welcome this change. I added a couple of (minor) inline comments, then it's good to go.
MANIFEST.in
Outdated
@@ -129,3 +112,4 @@ include scripts/who.py | |||
include scripts/winservices.py | |||
include setup.py | |||
include tox.ini | |||
graft tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please run make generate-manifest
instead?
docs/index.rst
Outdated
@@ -2607,7 +2607,7 @@ Running tests | |||
|
|||
There are two ways of running tests. If psutil is already installed use:: | |||
|
|||
$ python -m psutil.tests | |||
$ python -m tests | |||
|
|||
You can use this method as a quick way to make sure psutil fully works on your | |||
platform. If you have a copy of the source code you can also use:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole part ("there are 2 ways of running tests") should go away as from now on there is only one.
@@ -279,7 +279,7 @@ def main(): | |||
url='https://github.com/giampaolo/psutil', | |||
platforms='Platform Independent', | |||
license='BSD', | |||
packages=['psutil', 'psutil.tests'], | |||
packages=['psutil'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this is the main enhancement (remove tests from site-packages)
tests/README.rst
Outdated
@@ -4,8 +4,8 @@ Instructions for running tests | |||
* There are two ways of running tests. As a "user", if psutil is already | |||
installed and you just want to test it works:: | |||
|
|||
python -m psutil.tests --install-deps # install test deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, the "there are 2 ways of running tests" part should go away
Thanks for the review. I've made the suggested changes. For the changed documentation, if you like me to change any of the wording, please let me know. It is no problem to. |
tests/__main__.py
Outdated
@@ -7,7 +7,7 @@ | |||
""" | |||
Run unit tests. This is invoked by: | |||
|
|||
$ python -m psutil.tests | |||
$ python -m tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated. Let's just remove "this is invoked by...."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Cleanly separates tests from the package itself. Prevents the tests being installed to site-packages. Tests are still distributed with the source distribution by MANIFEST.in. Avoids installing tests in production environments, leading to less total code in the environment.
Excellent work. Merged. |
There's a problem with Python 2.7:
This:
|
I'm not seeing that error. When I run |
Why do you have a module named |
Looks like it's some third party package's tests:
|
I can fix it if I put this line before
Invoking tests as |
The problem here is that before tests were installed as an actual sub-package. The advantage of having tests inside
Not sure if there are better solutions. What do you think? |
Another option is to do away with
If preferred, this simple command could be wrapped in a script to make it shorter. I think this simplifies psutil's testing behavior and brings it more in line with default Python testing. I'm happy to make a PR for it if you agree. What do you think? |
|
We can maybe move the utilities to another file - say, |
I think keeping tests in |
The main point here should be avoiding to install tests in |
This reverts commit b578d2f.
I reverted this PR and I stand by my original suggestion of keeping tests in |
If you give me some time, I can try to resolve this. |
Sure. I suggest something along these lines:
|
|
Cleanly separates tests from the package itself. Prevents the tests being installed to site-packages. Tests are still distributed with the source distribution by
MANIFEST.in
.Avoids installing tests in production environments, leading to less total code in the environment.