-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add integration tests for upload with skip_existing #458
Conversation
Codecov Report
@@ Coverage Diff @@
## master #458 +/- ##
=========================================
+ Coverage 79.94% 80.74% +0.8%
=========================================
Files 14 14
Lines 748 748
Branches 108 108
=========================================
+ Hits 598 604 +6
+ Misses 113 110 -3
+ Partials 37 34 -3
Continue to review full report at Codecov.
|
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.
Thank you for doing this. I left several comments- if you're up to addressing them please do! If not, I'm happy to take this to the finish line for you. Just let me know what you're comfortable with.
tests/test_upload.py
Outdated
@@ -125,6 +125,81 @@ def test_deprecated_repo(tmpdir): | |||
) | |||
|
|||
|
|||
def test_upload_prints_skip_message_for_uploaded_package(tmpdir, capsys): | |||
pypirc = os.path.join(str(tmpdir), ".pypirc") |
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.
the tmpdir
fixture is a py.path.local
object, so you can do pypirc_path = tmpdir / ".pypirc"
.
tests/test_upload.py
Outdated
pypirc = os.path.join(str(tmpdir), ".pypirc") | ||
dists = ["tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"] | ||
|
||
with open(pypirc, "w") as fp: |
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.
You can use pypirc_path.write_text
to simplify this a little
https://py.readthedocs.io/en/latest/path.html#py._path.local.LocalPath.write_text
tests/test_upload.py
Outdated
""")) | ||
|
||
upload_settings = settings.Settings( | ||
repository_name="pypi", sign=None, identity=None, username=None, |
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.
Style nit: when argument lists end up taking up multiple lines, prefer to make each argument live on its own line:
upload_settings = settings.Settings(
repository_name="pypi",
sign=None,
identity=None,
...
)
Also, since most of these are just None
, can you omit them?
tests/test_upload.py
Outdated
password:bar | ||
""")) | ||
|
||
upload_settings = settings.Settings( |
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 seems repeated from the last case, can you pull it out into either a factory function or a fixture?
See "Use factory helpers to create complex collaborators" and "Use fixtures sparingly" in https://blog.thea.codes/my-python-testing-style-guide/
@theacodes Thanks for the feedback (and the article on testing)! I'm happy to put on my refactoring hat. |
- Simplify writing .pypirc - Remove default Settings - Reformat lines - Use WHEEL_FIXTURE
@theacodes I've made changes based on your suggestions. I went further with e911dd1, mostly as an exercise with pytest factory fixtures. Happy to edit/revert. |
Thank you, @bhrutledge! :) |
As a first task for a new contributor at the PyCon 2019 packaging sprint, @brainwane encouraged me to work on #7.
I see opportunities to refactor the tests via constants and fixtures, it seems reasonable to get
commands/upload.py
to 100% coverage, but I'd like to get feedback on this before proceeding.Before:
After: