Skip to content

Commit

Permalink
Prints a list of uploaded packages, cleaning up commits
Browse files Browse the repository at this point in the history
Prints succesfully and wrote test

prints all packages its attempting to upload before upload

Removed extra whitespaces from test_upload

Linting + formatting tests

Added New line after all package names have been printed
  • Loading branch information
Vikram Jayanthi committed Jun 8, 2020
1 parent 89aab15 commit a3ec4c1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os

import pretend
import pytest
import requests
Expand Down Expand Up @@ -72,6 +74,31 @@ def test_successs_prints_release_urls(upload_settings, stub_repository, capsys):
assert captured.out.count(NEW_RELEASE_URL) == 1


def test_successs_prints_uploaded_package_names_if_verbose(upload_settings, capsys):
"""Prints the name of each succesfully uploaded package."""
dists_to_upload = [
helpers.WHEEL_FIXTURE,
helpers.SDIST_FIXTURE,
helpers.NEW_SDIST_FIXTURE,
helpers.NEW_WHEEL_FIXTURE,
]

upload_settings.verbose = True

dists_to_upload_filenames = [
os.path.basename(filename) for filename in dists_to_upload
]

result = upload.upload(upload_settings, dists_to_upload)

assert result is None

captured = capsys.readouterr()

for uploaded_dist_filename in dists_to_upload_filenames:
assert captured.out.count(uploaded_dist_filename) == 1


def test_success_with_pre_signed_distribution(upload_settings, stub_repository):
"""Adds GPG signature provided by user to uploaded package."""
# Upload a pre-signed distribution
Expand Down
5 changes: 5 additions & 0 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def upload(upload_settings: settings.Settings, dists: List[str]) -> None:
repository = upload_settings.create_repository()
uploaded_packages = []

if upload_settings.verbose:
print("\nList of packages that will be uploaded:")
for package in uploads:
print(" " + os.path.basename(package))
print("\n")
for filename in uploads:
package = package_file.PackageFile.from_filename(
filename, upload_settings.comment
Expand Down

0 comments on commit a3ec4c1

Please sign in to comment.