diff --git a/rpmlint/checks/SpecCheck.py b/rpmlint/checks/SpecCheck.py index 997d974c..71d3ede6 100644 --- a/rpmlint/checks/SpecCheck.py +++ b/rpmlint/checks/SpecCheck.py @@ -79,6 +79,8 @@ filelist_regex = re.compile(r'\s+-f\s+\S+') pkgname_regex = re.compile(r'\s+(?:-n\s+)?(\S+)') tarball_regex = re.compile(r'\.(?:t(?:ar|[glx]z|bz2?)|zip)\b', re.IGNORECASE) +python_setup_test_regex = re.compile(r'^[^#]*(setup.py test)') + UNICODE_NBSP = u'\xa0' @@ -490,6 +492,10 @@ class SpecCheck(AbstractCheck): if len(res.group(0)) % 2: self.output.add_info('W', pkg, 'macro-in-comment', match) + # Test if the "python setup.py test" deprecated subcommand is used + if current_section == 'check' and python_setup_test_regex.search(line): + self.output.add_info('W', pkg, 'python-setup-test', line[:-1]) + # Last line read is not useful after this point pkg.current_linenum = None diff --git a/rpmlint/descriptions/SpecCheck.toml b/rpmlint/descriptions/SpecCheck.toml index 8914bc15..e9ed8aaa 100644 --- a/rpmlint/descriptions/SpecCheck.toml +++ b/rpmlint/descriptions/SpecCheck.toml @@ -184,3 +184,7 @@ the sign that someone didn't check if a patch is still needed and do not want to rediff it. It is usually better to rediff the patch and try to send it upstream. """ +python-setup-test=""" +The python setup.py test subcommand is deprecated and should be replaced with a +modern testing tool like %pytest or %pyunittest discover -v. +""" diff --git a/test/spec/python-setup-test.spec b/test/spec/python-setup-test.spec new file mode 100644 index 00000000..1a0fcf18 --- /dev/null +++ b/test/spec/python-setup-test.spec @@ -0,0 +1,34 @@ +Name: python-setup-test +Version: 1.0 +Release: 0 +Summary: python-setup-test warning +License: MIT +URL: https://www.example.com +Source: Source.tar.gz +BuildRequires: gcc +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%description +A test specfile with python setup.py test that is deprecated. + +%prep +%setup -q + +%build +%configure +%make_build + +%install +%make_install + +%check +%python_exec setup.py test + +%post +%postun + +%files +%license COPYING +%doc ChangeLog README + +%changelog diff --git a/test/test_speccheck.py b/test/test_speccheck.py index 8b2a0ebe..51960a38 100644 --- a/test/test_speccheck.py +++ b/test/test_speccheck.py @@ -1092,3 +1092,13 @@ def test_check_invalid_url_not_applied(package, speccheck): test.check_spec(pkg) out = output.print_results(output.results) assert 'W: invalid-url' not in out + + +@pytest.mark.parametrize('package', ['spec/python-setup-test']) +def test_python_setup_test(package, speccheck): + """Test if specfile has deprecated use of 'setup.py test'.""" + output, test = speccheck + pkg = get_tested_spec_package(package) + test.check_spec(pkg) + out = output.print_results(output.results) + assert 'W: python-setup-test' in out