diff options
author | ctolentino8 <ctolentino8@bloomberg.net> | 2018-09-24 10:32:45 +0100 |
---|---|---|
committer | Chandan Singh <chandan.devel@gmail.com> | 2018-11-02 16:41:54 +0000 |
commit | de59ebdbf755ca65c7c9d389204f6ce508f84e7e (patch) | |
tree | 546e291d2d52dee54120eab0a7045452484fd652 /tests/sources | |
parent | 7f79b9ce511f1421851821bf2928352ba569b8f0 (diff) | |
download | buildstream-de59ebdbf755ca65c7c9d389204f6ce508f84e7e.tar.gz |
plugins/sources/pip.py: Accomodate characters '-','.','_' for packages
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/pip.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/sources/pip.py b/tests/sources/pip.py index 8b4c213dc..6e1a347d9 100644 --- a/tests/sources/pip.py +++ b/tests/sources/pip.py @@ -3,6 +3,7 @@ import pytest from buildstream._exceptions import ErrorDomain from buildstream import _yaml +from buildstream.plugins.sources.pip import _match_package_name from tests.testutils import cli DATA_DIR = os.path.join( @@ -45,3 +46,22 @@ def test_no_packages(cli, tmpdir, datafiles): 'show', 'target.bst' ]) result.assert_main_error(ErrorDomain.SOURCE, None) + + +# Test that pip source parses tar ball names correctly for the ref +@pytest.mark.parametrize( + 'tarball, expected_name, expected_version', + [ + ('dotted.package-0.9.8.tar.gz', 'dotted.package', '0.9.8'), + ('hyphenated-package-2.6.0.tar.gz', 'hyphenated-package', '2.6.0'), + ('underscore_pkg-3.1.0.tar.gz', 'underscore_pkg', '3.1.0'), + ('numbers2and5-1.0.1.tar.gz', 'numbers2and5', '1.0.1'), + ('multiple.dots.package-5.6.7.tar.gz', 'multiple.dots.package', '5.6.7'), + ('multiple-hyphens-package-1.2.3.tar.gz', 'multiple-hyphens-package', '1.2.3'), + ('multiple_underscore_pkg-3.4.5.tar.gz', 'multiple_underscore_pkg', '3.4.5'), + ('shortversion-1.0.tar.gz', 'shortversion', '1.0'), + ('longversion-1.2.3.4.tar.gz', 'longversion', '1.2.3.4') + ]) +def test_match_package_name(tarball, expected_name, expected_version): + name, version = _match_package_name(tarball) + assert (expected_name, expected_version) == (name, version) |