fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
128 stars 39 forks source link

Unit tests fails when recompiling pyp2rpm-3.2.3-1.fc28.src.rpm #143

Closed hlovdal closed 6 years ago

hlovdal commented 6 years ago

Recompiling pyp2rpm-3.2.3-1.fc28.src.rpm on Fedora 26 fails on two of the unit tests due to slightly different names, python2-markupsafe vs python-markupsafe.

...
tests/test_virtualenv.py::TestVirtualEnv::test_get_dirs_differance[bin_diff4-package_diff4-expected4] PASSED

================================================================================================================= FAILURES ==================================================================================================================
_________________________________________________________________________________ TestDandifiedNameConvertor.test_rpm_name[MarkupSafe-2-python-markupsafe] __________________________________________________________________________________

self = <test_name_convertor.TestDandifiedNameConvertor object at 0x7f902e5dd208>, pypi_name = 'MarkupSafe', version = '2', expected = 'python-markupsafe'

    @pytest.mark.parametrize(('pypi_name', 'version', 'expected'), [
        ('Babel', '2', 'python2-babel'),
        ('Babel', '3', 'python3-babel'),
        ('MarkupSafe', '2', 'python-markupsafe'),
        ('MarkupSafe', '3', 'python3-markupsafe'),
        ('Jinja2', '2', 'python2-jinja2'),
        ('Jinja2', '3', 'python3-jinja2'),
        ('Sphinx', '2', 'python2-sphinx'),
        ('Sphinx', '3', 'python3-sphinx'),
        ('Cython', '2', 'python2-Cython'),
        ('Cython', '3', 'python3-Cython'),
        ('pytest', '2', 'python2-pytest'),
        ('pytest', '3', 'python3-pytest'),
        ('vertica', '2', 'vertica-python'),
        ('pycairo', '2', 'pycairo'),
        ('pycairo', '3', 'python3-cairo'),
        ('oslosphinx', '2', 'python2-oslo-sphinx'),
        ('oslosphinx', '3', 'python3-oslo-sphinx'),
        ('mock', '2', 'python2-mock'),
        ('mock', '3', 'python3-mock'),
    ])
    @pytest.mark.skipif(dnf is None, reason="Optional dependency DNF required")
    def test_rpm_name(self, pypi_name, version, expected):
>       assert self.dnc.rpm_name(pypi_name, version) == expected
E       AssertionError: assert 'python2-markupsafe' == 'python-markupsafe'
E         - python2-markupsafe
E         ?       -
E         + python-markupsafe

tests/test_name_convertor.py:83: AssertionError
============================================================================================================= warnings summary ==============================================================================================================
tests/test_integration.py::TestFileEnvironment
  cannot collect test class 'TestFileEnvironment' because it has a __init__ constructor

-- Docs: http://doc.pytest.org/en/latest/warnings.html
============================================================================================================ 15 tests deselected ============================================================================================================
=============================================================================== 1 failed, 295 passed, 8 skipped, 15 deselected, 1 warnings in 967.12 seconds ================================================================================

Similar for the second one. Workaround: adding rm tests/test_virtualenv.py tests/test_name_convertor.py in the build section in the spec file.

mcyprian commented 6 years ago

Thanks for reporting this, results of name conversion in this test depend on actual RPM package names in Fedora repositories, they change from time to time and expected values were outdated. This was fixed here. virtualenv-api is listed as extras_require, if it is not installed, test_virtualenv should be skipped. I am working on PR to fix this as well.