Adapt %%py_dist_name to keep square brackets
So %{py3_dist foo[bar]} works as expected. Add tests.
This commit is contained in:
parent
763d24cc5c
commit
59abe832d4
@ -70,7 +70,7 @@
|
||||
# Converts Python dist name to a canonical format
|
||||
%py_dist_name() %{lua:\
|
||||
name = rpm.expand("%{?1:%{1}}");\
|
||||
canonical = string.gsub(string.lower(name), "%W+", "-");\
|
||||
canonical = string.gsub(string.lower(name), "[^%w%[%]]+", "-");\
|
||||
print(canonical);\
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||
%changelog
|
||||
* Wed Jul 08 2020 Miro Hrončok <mhroncok@redhat.com> - 3.9-5
|
||||
- Introduce %%python_extras_subpkg
|
||||
- Adapt %%py_dist_name to keep square brackets
|
||||
- https://fedoraproject.org/wiki/Changes/PythonExtras
|
||||
|
||||
* Tue Jun 16 2020 Lumír Balhar <lbalhar@redhat.com> - 3.9-4
|
||||
|
@ -3,6 +3,8 @@ import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
X_Y = f'{sys.version_info[0]}.{sys.version_info[1]}'
|
||||
XY = f'{sys.version_info[0]}{sys.version_info[1]}'
|
||||
|
||||
@ -24,6 +26,30 @@ def rpm_eval(expression, fails=False, **kwargs):
|
||||
return cp.stdout.strip().splitlines()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('argument, result', [
|
||||
('a', 'a'),
|
||||
('a-a', 'a-a'),
|
||||
('a_a', 'a-a'),
|
||||
('a.a', 'a-a'),
|
||||
('a---a', 'a-a'),
|
||||
('a-_-a', 'a-a'),
|
||||
('a-_-a', 'a-a'),
|
||||
('a[b]', 'a[b]'),
|
||||
('Aha[Boom]', 'aha[boom]'),
|
||||
('a.a[b.b]', 'a-a[b-b]'),
|
||||
])
|
||||
def test_pydist_name(argument, result):
|
||||
assert rpm_eval(f'%py_dist_name {argument}') == [result]
|
||||
|
||||
|
||||
def test_py2_dist():
|
||||
assert rpm_eval(f'%py2_dist Aha[Boom] a') == ['python2dist(aha[boom]) python2dist(a)']
|
||||
|
||||
|
||||
def test_py3_dist():
|
||||
assert rpm_eval(f'%py3_dist Aha[Boom] a') == ['python3dist(aha[boom]) python3dist(a)']
|
||||
|
||||
|
||||
def test_python_provide_python():
|
||||
assert rpm_eval('%python_provide python-foo') == []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user