openSUSE / py2pack

Generate distribution packages from PyPI
Apache License 2.0
69 stars 40 forks source link

0.8.7: pytest is failing #161

Open kloczek opened 2 years ago

kloczek commented 2 years ago

+++ pytest is failing I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-py2pack-0.8.7-24.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-py2pack-0.8.7-24.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/py2pack-0.8.7 collected 48 items test/test_py2pack.py FF................F.......F [ 56%] test/test_requires.py ........... [ 79%] test/test_template.py FFFFFF [ 91%] test/test_utils.py .... [100%] ================================================================================= FAILURES ================================================================================= _______ Py2packTestCase.test__get_source_url_1___py2pack____py2pack_0_6_4_tar_gz____https___files_pythonhosted_org_packages_source_p_py2pack_py2pack_0_6_4_tar_gz__ ________ self = pypi_name = 'py2pack', extension = 'py2pack-0.6.4.tar.gz', expected_url = 'https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz' @data( ('py2pack', 'py2pack-0.6.4.tar.gz', 'https://files.pythonhosted.org/packages/source/' 'p/py2pack/py2pack-0.6.4.tar.gz'), ("SQLAlchemy", 'SQLAlchemy-1.0.5.tar.gz', 'https://files.pythonhosted.org/packages/source/' 'S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz'), ) @unpack def test__get_source_url(self, pypi_name, extension, expected_url): > self.assertEqual(py2pack._get_source_url(pypi_name, extension), expected_url) E AssertionError: 'https://pypi.io/packages/source/p/py2pack/py2pack-0.6.4.tar.gz' != 'https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz' E - https://pypi.io/packages/source/p/py2pack/py2pack-0.6.4.tar.gz E ? ^^ - E + https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz E ? ++++++ ^^^^^^^^^^ ++ test/test_py2pack.py:46: AssertionError _ Py2packTestCase.test__get_source_url_2___SQLAlchemy____SQLAlchemy_1_0_5_tar_gz____https___files_pythonhosted_org_packages_source_S_SQLAlchemy_SQLAlchemy_1_0_5_tar_gz__ __ self = pypi_name = 'SQLAlchemy', extension = 'SQLAlchemy-1.0.5.tar.gz', expected_url = 'https://files.pythonhosted.org/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz' @data( ('py2pack', 'py2pack-0.6.4.tar.gz', 'https://files.pythonhosted.org/packages/source/' 'p/py2pack/py2pack-0.6.4.tar.gz'), ("SQLAlchemy", 'SQLAlchemy-1.0.5.tar.gz', 'https://files.pythonhosted.org/packages/source/' 'S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz'), ) @unpack def test__get_source_url(self, pypi_name, extension, expected_url): > self.assertEqual(py2pack._get_source_url(pypi_name, extension), expected_url) E AssertionError: 'https://pypi.io/packages/source/S/SQLAlchemy/SQLA[15 chars]r.gz' != 'https://files.pythonhosted.org/packages/source/S/[30 chars]r.gz' E - https://pypi.io/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz E ? ^^ - E + https://files.pythonhosted.org/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz E ? ++++++ ^^^^^^^^^^ ++ test/test_py2pack.py:46: AssertionError _________________________________________________________________ Py2packTestCase.test_newest_download_url _________________________________________________________________ self = def test_newest_download_url(self): > py2pack.fetch_data(self.args) test/test_py2pack.py:59: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = .Args object at 0x7fa862cae130> def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ________________________________________________________________________ Py2packTestCase.test_show _________________________________________________________________________ self = def test_show(self): > py2pack.show(self.args) test/test_py2pack.py:56: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:88: in show fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = .Args object at 0x7fa862c65d60> def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError _____________________________________________________________________ test_template[fedora.spec-False] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_fedora_spec_Fals0'), template = 'fedora.spec', fetch_tarball = False @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: py2pack.fetch(args) py2pack.generate(args) else: with pytest.warns(UserWarning, match="No tarball"): > py2pack.generate(args) test/test_template.py:64: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:233: in generate fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError _____________________________________________________________________ test_template[mageia.spec-False] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_mageia_spec_Fals0'), template = 'mageia.spec', fetch_tarball = False @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: py2pack.fetch(args) py2pack.generate(args) else: with pytest.warns(UserWarning, match="No tarball"): > py2pack.generate(args) test/test_template.py:64: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:233: in generate fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ________________________________________________________________ test_template[opensuse-legacy.spec-False] _________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_opensuse_legacy_0'), template = 'opensuse-legacy.spec', fetch_tarball = False @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: py2pack.fetch(args) py2pack.generate(args) else: with pytest.warns(UserWarning, match="No tarball"): > py2pack.generate(args) test/test_template.py:64: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:233: in generate fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ____________________________________________________________________ test_template[opensuse.dsc-False] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_opensuse_dsc_Fal0'), template = 'opensuse.dsc', fetch_tarball = False @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: py2pack.fetch(args) py2pack.generate(args) else: with pytest.warns(UserWarning, match="No tarball"): > py2pack.generate(args) test/test_template.py:64: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:233: in generate fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ____________________________________________________________________ test_template[opensuse.spec-False] ____________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_opensuse_spec_Fa0'), template = 'opensuse.spec', fetch_tarball = False @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: py2pack.fetch(args) py2pack.generate(args) else: with pytest.warns(UserWarning, match="No tarball"): > py2pack.generate(args) test/test_template.py:64: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:233: in generate fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ____________________________________________________________________ test_template[opensuse.spec-True] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-871/test_template_opensuse_spec_Tr0'), template = 'opensuse.spec', fetch_tarball = True @pytest.mark.parametrize('template, fetch_tarball', [('fedora.spec', False), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), ('opensuse.spec', False), ('opensuse.spec', True)]) def test_template(tmpdir, template, fetch_tarball): """ Test if generated specfile equals to stored one. """ args = Args() args.template = template base, ext = template.split(".") suffix = '-augmented' if fetch_tarball else '' filename = "{}{}.{}".format(base, suffix, ext) args.filename = filename with tmpdir.as_cwd(): if fetch_tarball: > py2pack.fetch(args) test/test_template.py:60: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ py2pack/__init__.py:94: in fetch fetch_data(args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) > releases = args.fetched_data['releases'] E KeyError: 'releases' py2pack/__init__.py:284: KeyError ========================================================================= short test summary info ========================================================================== FAILED test/test_py2pack.py::Py2packTestCase::test__get_source_url_1___py2pack____py2pack_0_6_4_tar_gz____https___files_pythonhosted_org_packages_source_p_py2pack_py2pack_0_6_4_tar_gz__ FAILED test/test_py2pack.py::Py2packTestCase::test__get_source_url_2___SQLAlchemy____SQLAlchemy_1_0_5_tar_gz____https___files_pythonhosted_org_packages_source_S_SQLAlchemy_SQLAlchemy_1_0_5_tar_gz__ FAILED test/test_py2pack.py::Py2packTestCase::test_newest_download_url - KeyError: 'releases' FAILED test/test_py2pack.py::Py2packTestCase::test_show - KeyError: 'releases' FAILED test/test_template.py::test_template[fedora.spec-False] - KeyError: 'releases' FAILED test/test_template.py::test_template[mageia.spec-False] - KeyError: 'releases' FAILED test/test_template.py::test_template[opensuse-legacy.spec-False] - KeyError: 'releases' FAILED test/test_template.py::test_template[opensuse.dsc-False] - KeyError: 'releases' FAILED test/test_template.py::test_template[opensuse.spec-False] - KeyError: 'releases' FAILED test/test_template.py::test_template[opensuse.spec-True] - KeyError: 'releases' ====================================================================== 10 failed, 38 passed in 11.20s ====================================================================== ```
jayvdb commented 2 years ago

Running tox -e py310 locally on openSUSE Tumbleweed I see a subset of those errors.

FAILED test/test_py2pack.py::Py2packTestCase::test_newest_download_url - KeyError: 'releases'
FAILED test/test_py2pack.py::Py2packTestCase::test_show - KeyError: 'releases'
FAILED test/test_template.py::test_template[fedora.spec-False] - KeyError: 'releases'
FAILED test/test_template.py::test_template[mageia.spec-False] - KeyError: 'releases'
FAILED test/test_template.py::test_template[opensuse-legacy.spec-False] - KeyError: 'releases'
FAILED test/test_template.py::test_template[opensuse.dsc-False] - KeyError: 'releases'
FAILED test/test_template.py::test_template[opensuse.spec-False] - KeyError: 'releases'
FAILED test/test_template.py::test_template[opensuse.spec-True] - KeyError: 'releases'
mcepl commented 2 years ago

Fixed by the above merged pull request.

kloczek commented 2 years ago

Tested and pytest still fails

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-py2pack-0.8.7-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-py2pack-0.8.7-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.14, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/py2pack-0.8.7
collected 48 items

test/test_py2pack.py FF.........................                                                                                                                     [ 56%]
test/test_requires.py ...........                                                                                                                                    [ 79%]
test/test_template.py FFF.FF                                                                                                                                         [ 91%]
test/test_utils.py ....                                                                                                                                              [100%]

================================================================================= FAILURES =================================================================================
_______ Py2packTestCase.test__get_source_url_1___py2pack____py2pack_0_6_4_tar_gz____https___files_pythonhosted_org_packages_source_p_py2pack_py2pack_0_6_4_tar_gz__ ________

self = <test.test_py2pack.Py2packTestCase testMethod=test__get_source_url_1___py2pack____py2pack_0_6_4_tar_gz____https___files_pythonhosted_org_packages_source_p_py2pack_py2pack_0_6_4_tar_gz__>
pypi_name = 'py2pack', extension = 'py2pack-0.6.4.tar.gz', expected_url = 'https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz'

    @data(
        ('py2pack', 'py2pack-0.6.4.tar.gz',
         'https://files.pythonhosted.org/packages/source/'
         'p/py2pack/py2pack-0.6.4.tar.gz'),
        ("SQLAlchemy", 'SQLAlchemy-1.0.5.tar.gz',
         'https://files.pythonhosted.org/packages/source/'
         'S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz'),
    )
    @unpack
    def test__get_source_url(self, pypi_name, extension, expected_url):
>       self.assertEqual(py2pack._get_source_url(pypi_name, extension),
                         expected_url)
E       AssertionError: 'https://pypi.io/packages/source/p/py2pack/py2pack-0.6.4.tar.gz' != 'https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz'
E       - https://pypi.io/packages/source/p/py2pack/py2pack-0.6.4.tar.gz
E       ?           ^^ -
E       + https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-0.6.4.tar.gz
E       ?         ++++++  ^^^^^^^^^^  ++

test/test_py2pack.py:46: AssertionError
_ Py2packTestCase.test__get_source_url_2___SQLAlchemy____SQLAlchemy_1_0_5_tar_gz____https___files_pythonhosted_org_packages_source_S_SQLAlchemy_SQLAlchemy_1_0_5_tar_gz__ __

self = <test.test_py2pack.Py2packTestCase testMethod=test__get_source_url_2___SQLAlchemy____SQLAlchemy_1_0_5_tar_gz____https___files_pythonhosted_org_packages_source_S_SQLAlchemy_SQLAlchemy_1_0_5_tar_gz__>
pypi_name = 'SQLAlchemy', extension = 'SQLAlchemy-1.0.5.tar.gz', expected_url = 'https://files.pythonhosted.org/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz'

    @data(
        ('py2pack', 'py2pack-0.6.4.tar.gz',
         'https://files.pythonhosted.org/packages/source/'
         'p/py2pack/py2pack-0.6.4.tar.gz'),
        ("SQLAlchemy", 'SQLAlchemy-1.0.5.tar.gz',
         'https://files.pythonhosted.org/packages/source/'
         'S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz'),
    )
    @unpack
    def test__get_source_url(self, pypi_name, extension, expected_url):
>       self.assertEqual(py2pack._get_source_url(pypi_name, extension),
                         expected_url)
E       AssertionError: 'https://pypi.io/packages/source/S/SQLAlchemy/SQLA[15 chars]r.gz' != 'https://files.pythonhosted.org/packages/source/S/[30 chars]r.gz'
E       - https://pypi.io/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz
E       ?           ^^ -
E       + https://files.pythonhosted.org/packages/source/S/SQLAlchemy/SQLAlchemy-1.0.5.tar.gz
E       ?         ++++++  ^^^^^^^^^^  ++

test/test_py2pack.py:46: AssertionError
_____________________________________________________________________ test_template[fedora.spec-False] _____________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-7/test_template_fedora_spec_Fals0'), template = 'fedora.spec', fetch_tarball = False

    @pytest.mark.parametrize('template, fetch_tarball',
                             [('fedora.spec', False),
                              ('mageia.spec', False),
                              ('opensuse-legacy.spec', False),
                              ('opensuse.dsc', False),
                              ('opensuse.spec', False),
                              ('opensuse.spec', True)])
    def test_template(tmpdir, template, fetch_tarball):
        """ Test if generated specfile equals to stored one. """
        if (template, fetch_tarball, sys.version_info[:2]) == ('opensuse.spec', True, (3, 6)):
            raise unittest.SkipTest('This combination of tests fails ATM.')
        args = Args()
        args.template = template
        base, ext = template.split(".")
        suffix = '-augmented' if fetch_tarball else ''
        filename = "{}{}.{}".format(base, suffix, ext)
        args.filename = filename
        with tmpdir.as_cwd():
            if fetch_tarball:
                py2pack.fetch(args)
                py2pack.generate(args)
            else:
                with pytest.warns(UserWarning, match="No tarball"):
                    py2pack.generate(args)
            with open(filename) as filehandle:
                written_spec = filehandle.read()
        reference = os.path.join(compare_dir, 'py2pack-{}'.format(filename))
        with open(reference) as filehandle:
            required = filehandle.read()
        required = required.replace('__USER__', username, 1)
        required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
>       assert written_spec == required
E       AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
E         Skipping 289 identical leading characters in diff, use -v to show
E         -   https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?           ------  ^^ -----------
E         +   https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?             ^^^^
E           BuildRoot:      %{_tmppath}/%{name}-%{version}-build
E           BuildRequires:  python-devel...
E
E         ...Full output truncated (155 lines hidden), use '-vv' to show

test/test_template.py:76: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
generating spec file for py2pack...
_____________________________________________________________________ test_template[mageia.spec-False] _____________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-7/test_template_mageia_spec_Fals0'), template = 'mageia.spec', fetch_tarball = False

    @pytest.mark.parametrize('template, fetch_tarball',
                             [('fedora.spec', False),
                              ('mageia.spec', False),
                              ('opensuse-legacy.spec', False),
                              ('opensuse.dsc', False),
                              ('opensuse.spec', False),
                              ('opensuse.spec', True)])
    def test_template(tmpdir, template, fetch_tarball):
        """ Test if generated specfile equals to stored one. """
        if (template, fetch_tarball, sys.version_info[:2]) == ('opensuse.spec', True, (3, 6)):
            raise unittest.SkipTest('This combination of tests fails ATM.')
        args = Args()
        args.template = template
        base, ext = template.split(".")
        suffix = '-augmented' if fetch_tarball else ''
        filename = "{}{}.{}".format(base, suffix, ext)
        args.filename = filename
        with tmpdir.as_cwd():
            if fetch_tarball:
                py2pack.fetch(args)
                py2pack.generate(args)
            else:
                with pytest.warns(UserWarning, match="No tarball"):
                    py2pack.generate(args)
            with open(filename) as filehandle:
                written_spec = filehandle.read()
        reference = os.path.join(compare_dir, 'py2pack-{}'.format(filename))
        with open(reference) as filehandle:
            required = filehandle.read()
        required = required.replace('__USER__', username, 1)
        required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
>       assert written_spec == required
E       AssertionError: assert '%define mod_..._sitelib}/*\n' == '%define mod_..._sitelib}/*\n'
E         Skipping 292 identical leading characters in diff, use -v to show
E         -   https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?           ------  ^^ -----------
E         +   https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?             ^^^^
E           BuildRoot:      %{_tmppath}/%{name}-%{version}-buildroot
E           BuildRequires:  python-devel...
E
E         ...Full output truncated (21 lines hidden), use '-vv' to show

test/test_template.py:76: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
generating spec file for py2pack...
________________________________________________________________ test_template[opensuse-legacy.spec-False] _________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-7/test_template_opensuse_legacy_0'), template = 'opensuse-legacy.spec', fetch_tarball = False

    @pytest.mark.parametrize('template, fetch_tarball',
                             [('fedora.spec', False),
                              ('mageia.spec', False),
                              ('opensuse-legacy.spec', False),
                              ('opensuse.dsc', False),
                              ('opensuse.spec', False),
                              ('opensuse.spec', True)])
    def test_template(tmpdir, template, fetch_tarball):
        """ Test if generated specfile equals to stored one. """
        if (template, fetch_tarball, sys.version_info[:2]) == ('opensuse.spec', True, (3, 6)):
            raise unittest.SkipTest('This combination of tests fails ATM.')
        args = Args()
        args.template = template
        base, ext = template.split(".")
        suffix = '-augmented' if fetch_tarball else ''
        filename = "{}{}.{}".format(base, suffix, ext)
        args.filename = filename
        with tmpdir.as_cwd():
            if fetch_tarball:
                py2pack.fetch(args)
                py2pack.generate(args)
            else:
                with pytest.warns(UserWarning, match="No tarball"):
                    py2pack.generate(args)
            with open(filename) as filehandle:
                written_spec = filehandle.read()
        reference = os.path.join(compare_dir, 'py2pack-{}'.format(filename))
        with open(reference) as filehandle:
            required = filehandle.read()
        required = required.replace('__USER__', username, 1)
        required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
>       assert written_spec == required
E       AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
E         Skipping 947 identical leading characters in diff, use -v to show
E         -   https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?           ------  ^^ -----------
E         +   https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?             ^^^^
E           BuildRequires:  python-setuptools
E           BuildRoot:      %{_tmppath}/%{name}-%{version}-build...
E
E         ...Full output truncated (153 lines hidden), use '-vv' to show

test/test_template.py:76: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
generating spec file for py2pack...
____________________________________________________________________ test_template[opensuse.spec-False] ____________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-7/test_template_opensuse_spec_Fa0'), template = 'opensuse.spec', fetch_tarball = False

    @pytest.mark.parametrize('template, fetch_tarball',
                             [('fedora.spec', False),
                              ('mageia.spec', False),
                              ('opensuse-legacy.spec', False),
                              ('opensuse.dsc', False),
                              ('opensuse.spec', False),
                              ('opensuse.spec', True)])
    def test_template(tmpdir, template, fetch_tarball):
        """ Test if generated specfile equals to stored one. """
        if (template, fetch_tarball, sys.version_info[:2]) == ('opensuse.spec', True, (3, 6)):
            raise unittest.SkipTest('This combination of tests fails ATM.')
        args = Args()
        args.template = template
        base, ext = template.split(".")
        suffix = '-augmented' if fetch_tarball else ''
        filename = "{}{}.{}".format(base, suffix, ext)
        args.filename = filename
        with tmpdir.as_cwd():
            if fetch_tarball:
                py2pack.fetch(args)
                py2pack.generate(args)
            else:
                with pytest.warns(UserWarning, match="No tarball"):
                    py2pack.generate(args)
            with open(filename) as filehandle:
                written_spec = filehandle.read()
        reference = os.path.join(compare_dir, 'py2pack-{}'.format(filename))
        with open(reference) as filehandle:
            required = filehandle.read()
        required = required.replace('__USER__', username, 1)
        required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
>       assert written_spec == required
E       AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
E         Skipping 991 identical leading characters in diff, use -v to show
E         -   https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?           ------  ^^ -----------
E         +   https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz
E         ?             ^^^^
E           BuildRequires:  python-rpm-macros
E           BuildRequires:  %{python_module setuptools}...
E
E         ...Full output truncated (156 lines hidden), use '-vv' to show

test/test_template.py:76: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
generating spec file for py2pack...
____________________________________________________________________ test_template[opensuse.spec-True] _____________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-7/test_template_opensuse_spec_Tr0'), template = 'opensuse.spec', fetch_tarball = True

    @pytest.mark.parametrize('template, fetch_tarball',
                             [('fedora.spec', False),
                              ('mageia.spec', False),
                              ('opensuse-legacy.spec', False),
                              ('opensuse.dsc', False),
                              ('opensuse.spec', False),
                              ('opensuse.spec', True)])
    def test_template(tmpdir, template, fetch_tarball):
        """ Test if generated specfile equals to stored one. """
        if (template, fetch_tarball, sys.version_info[:2]) == ('opensuse.spec', True, (3, 6)):
            raise unittest.SkipTest('This combination of tests fails ATM.')
        args = Args()
        args.template = template
        base, ext = template.split(".")
        suffix = '-augmented' if fetch_tarball else ''
        filename = "{}{}.{}".format(base, suffix, ext)
        args.filename = filename
        with tmpdir.as_cwd():
            if fetch_tarball:
                py2pack.fetch(args)
                py2pack.generate(args)
            else:
                with pytest.warns(UserWarning, match="No tarball"):
                    py2pack.generate(args)
            with open(filename) as filehandle:
                written_spec = filehandle.read()
        reference = os.path.join(compare_dir, 'py2pack-{}'.format(filename))
        with open(reference) as filehandle:
            required = filehandle.read()
        required = required.replace('__USER__', username, 1)
        required = required.replace('__YEAR__', str(datetime.date.today().year), 1)
>       assert written_spec == required
E       AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
E         Skipping 812 identical leading characters in diff, use -v to show
E         -       0.8.5
E         ?           ^
E         +       0.8.7
E         ?           ^
E           Release:        0
E           Summary:        Generate distribution packages from PyPI...
E
E         ...Full output truncated (62 lines hidden), use '-vv' to show

test/test_template.py:76: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
downloading package py2pack-0.8.5...
from https://pypi.io/packages/source/p/py2pack/py2pack-0.8.5.tar.gz
generating spec file for py2pack...
========================================================================= short test summary info ==========================================================================
FAILED test/test_py2pack.py::Py2packTestCase::test__get_source_url_1___py2pack____py2pack_0_6_4_tar_gz____https___files_pythonhosted_org_packages_source_p_py2pack_py2pack_0_6_4_tar_gz__
FAILED test/test_py2pack.py::Py2packTestCase::test__get_source_url_2___SQLAlchemy____SQLAlchemy_1_0_5_tar_gz____https___files_pythonhosted_org_packages_source_S_SQLAlchemy_SQLAlchemy_1_0_5_tar_gz__
FAILED test/test_template.py::test_template[fedora.spec-False] - AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
FAILED test/test_template.py::test_template[mageia.spec-False] - AssertionError: assert '%define mod_..._sitelib}/*\n' == '%define mod_..._sitelib}/*\n'
FAILED test/test_template.py::test_template[opensuse-legacy.spec-False] - AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
FAILED test/test_template.py::test_template[opensuse.spec-False] - AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
FAILED test/test_template.py::test_template[opensuse.spec-True] - AssertionError: assert '#\n# spec fi...n%changelog\n' == '#\n# spec fi...n%changelog\n'
====================================================================== 7 failed, 41 passed in 14.16s =======================================================================
mcepl commented 2 years ago

@danigm Could you take a look, please?

danigm commented 2 years ago

It's weird, I can't reproduce this problem. It looks like the source url is different from template, but we're using a hardcoded value here: https://github.com/openSUSE/py2pack/blob/master/py2pack/__init__.py#L223

So I don't know where these https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz strings comes from.

danigm commented 2 years ago

@kloczek can you give more information about how you run these tests? the only place where I found the pypi.io path is versions before 0.6.5. This commit changes the path: https://github.com/openSUSE/py2pack/commit/9e788d38b655253f3a97ea5f20d90bd378ca382d

kloczek commented 2 years ago

It's weird, I can't reproduce this problem. It looks like the source url is different from template, but we're using a hardcoded value here: https://github.com/openSUSE/py2pack/blob/master/py2pack/__init__.py#L223

So I don't know where these https://pypi.io/packages/source/p/py2pack/py2pack-%{version}.tar.gz strings comes from.

I'm using autogenerated from git tag tar ball (not pypi sdist one).