def test_find_dists_expands_globs(): files = sorted(upload.find_dists(['twine/__*.py'])) expected = [ os.path.join('twine', '__init__.py'), os.path.join('twine', '__main__.py') ] assert expected == files
def test_find_dists_handles_real_files(): expected = [ 'twine/__init__.py', 'twine/__main__.py', 'twine/cli.py', 'twine/utils.py', 'twine/wheel.py' ] files = upload.find_dists(expected) assert expected == files
def upload(self, poet): """ Upload packages represented by a Poet instance. :param poet: The Poet instance representing the package. :type poet: poet.poet.Poet """ skip_existing = False dists = find_dists([ os.path.join(os.path.join(poet.base_dir, 'dist'), '{}-{}*'.format(poet.name, poet.version)) ]) uploads = [i for i in dists if not i.endswith(".asc")] for filename in uploads: package = PackageFile.from_filename(filename, None) skip_message = ( " - Skipping <comment>{0}</> because it appears to already exist" .format(package.basefilename)) # Note: The skip_existing check *needs* to be first, because otherwise # we're going to generate extra HTTP requests against a hardcoded # URL for no reason. if skip_existing and self._repository.package_is_uploaded(package): self._output.writeln(skip_message) continue resp = self._repository.upload(package) # Bug 92. If we get a redirect we should abort because something seems # funky. The behaviour is not well defined and redirects being issued # by PyPI should never happen in reality. This should catch malicious # redirects as well. if resp.is_redirect: raise RedirectDetected( ('"{0}" attempted to redirect to "{1}" during upload.' ' Aborting...').format(self._repository.url, resp.headers["location"])) if skip_upload(resp, skip_existing, package): self._output.writeln(skip_message) continue twine.utils.check_status_code(resp) # Bug 28. Try to silence a ResourceWarning by clearing the connection # pool. self._repository.close()
def test_find_dists_errors_on_invalid_globs(): with pytest.raises(ValueError): upload.find_dists(['twine/*.rb'])
def test_find_dists_expands_globs(): files = sorted(upload.find_dists(['twine/__*.py'])) expected = ['twine/__init__.py', 'twine/__main__.py'] assert expected == files
def test_find_dists_handles_real_files(): expected = ['twine/__init__.py', 'twine/__main__.py', 'twine/cli.py', 'twine/utils.py', 'twine/wheel.py'] files = upload.find_dists(expected) assert expected == files