toabctl / metaextract

get metadata for python modules
Apache License 2.0
7 stars 4 forks source link

Failing tests test_run_setup_py_from_dir #20

Open mcepl opened 2 months ago

mcepl commented 2 months ago

When running the test suit, all calls to test_run_setup_py_from_dir fail:

[   14s] _ TestMetaExtract.test_run_setup_py_from_dir[setuptools_simple-expected_data0] _
[   14s] 
[   14s] self = <metaextract.tests.test_metaextract.TestMetaExtract object at 0x7f5c1b2a1db0>
[   14s] tmpdir = local('/tmp/pytest-of-abuild/pytest-0/test_run_setup_py_from_dir_set0')
[   14s] monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f5c1b2c1b70>
[   14s] fixture_name = 'setuptools_simple'
[   14s] expected_data = {'data_files': None, 'entry_points': None, 'extras_require': {'extra1': ['pkg1']}, 'has_ext_modules': None, ...}
[   14s] 
[   14s]     @pytest.mark.parametrize("fixture_name,expected_data", [
[   14s]         (
[   14s]             "setuptools_simple", {
[   14s]                 'entry_points': None, 'extras_require': {'extra1': ['pkg1']},
[   14s]                 'install_requires': ['bar', 'foo'], 'python_requires': None,
[   14s]                 'setup_requires': [], 'has_ext_modules': None,
[   14s]                 'scripts': None, 'data_files': None, 'tests_require': None}
[   14s]         ),
[   14s]         (
[   14s]             "setuptools_simple_unicode", {
[   14s]                 'entry_points': None, 'extras_require': {
[   14s]                     'extra1': ['pkg1'], 'extra2': ['pkg2', 'pkg3']},
[   14s]                 'install_requires': ['bar', 'foo'], 'python_requires': None,
[   14s]                 'setup_requires': [], 'has_ext_modules': None,
[   14s]                 'scripts': None, 'data_files': None, 'tests_require': None}
[   14s]         ),
[   14s]         (
[   14s]             "setuptools_simple_unicode_and_header", {
[   14s]                 'entry_points': None, 'extras_require': {},
[   14s]                 'install_requires': ['bar', 'foo'], 'python_requires': None,
[   14s]                 'setup_requires': [], 'has_ext_modules': None,
[   14s]                 'scripts': None, 'data_files': None, 'tests_require': None}
[   14s]         ),
[   14s]         (
[   14s]             "setuptools_full", {
[   14s]                 'install_requires': ['bar', 'foo'], 'setup_requires': [],
[   14s]                 'python_requires': '>=2.6,!=3.0.*,!=3.1.*,!=3.2.*',
[   14s]                 'has_ext_modules': None, 'scripts': ['scripts/testpkg'],
[   14s]                 'data_files': [
[   14s]                     ['man/man1', ['doc/testpkg.1']],
[   14s]                     ['share/doc/testpgk',
[   14s]                      ['AUTHORS', 'LICENSE', 'README.rst']],
[   14s]                     ['share/doc/testpkg/html', ['doc/testpkg.html']],
[   14s]                 ], 'tests_require': ['testpkg1'], 'entry_points':
[   14s]                 {
[   14s]                     'console_scripts': ['testpkgp1=testpkg:main']
[   14s]                 },
[   14s]                 'extras_require': {
[   14s]                     'extra1': ['ex11', 'ex12'],
[   14s]                     'extra2': ['ex21>=3.4', 'ex22!=0.15.0,>=0.11.0']
[   14s]                 },
[   14s]                 'version': '1.2.3',
[   14s]                 'name': 'testpkg',
[   14s]                 'fullname': 'testpkg-1.2.3',
[   14s]                 'description': 'desc',
[   14s]                 'long_description': 'long desc',
[   14s]                 'classifiers': ['Intended Audience :: Developers'],
[   14s]                 'license': 'Apache-2.0',
[   14s]     
[   14s]             }
[   14s]         ),
[   14s]         (
[   14s]             "distutils_simple",
[   14s]             {'data_files': None, 'has_ext_modules': None, 'scripts': None,
[   14s]              'version': '1.0'}
[   14s]         ),
[   14s]         (
[   14s]             "distutils_with_extension",
[   14s]             {'data_files': None, 'has_ext_modules': True, 'scripts': None}
[   14s]         ),
[   14s]         (
[   14s]             "pbr_simple",
[   14s]             {'entry_points': {'console_scripts': ['entry2 = pkg1:main']},
[   14s]              'extras_require': {}, 'install_requires': [],
[   14s]              'python_requires': None, 'setup_requires': ['pbr>=1.0'],
[   14s]              'has_ext_modules': None, 'scripts': None, 'data_files': None,
[   14s]              'tests_require': None,
[   14s]              'version': '1'}
[   14s]         ),
[   14s]         (
[   14s]             "pyproject",
[   14s]             {
[   14s]                 'install_requires': ['bar', 'foo'], 'setup_requires': [],
[   14s]                 'python_requires': '!=3.0.*,!=3.1.*,!=3.2.*,>=2.6',
[   14s]                 'entry_points':
[   14s]                 {
[   14s]                     'console_scripts': ['testpkgp1 = testpkg:main']
[   14s]                 },
[   14s]                 'extras_require': {
[   14s]                     'extra1': ['ex11', 'ex12'],
[   14s]                     'extra2': ['ex21>=3.4', 'ex22!=0.15.0,>=0.11.0']
[   14s]                 },
[   14s]                 'version': '1.2.3',
[   14s]                 'name': 'testpkg',
[   14s]                 'fullname': 'testpkg-1.2.3',
[   14s]                 'description': 'desc',
[   14s]                 'long_description': 'long desc\n',
[   14s]                 'classifiers': ['Intended Audience :: Developers'],
[   14s]                 'license': 'Apache-2.0',
[   14s]             }
[   14s]         ),
[   14s]     ])
[   14s]     def test_run_setup_py_from_dir(self, tmpdir, monkeypatch,
[   14s]                                    fixture_name, expected_data):
[   14s]         if fixture_name == "pyproject" and sys.version_info < (3, 0):
[   14s]             pytest.skip("pyproject.toml is not supported for python2")
[   14s]     
[   14s]         # the given fixture name is the directory name in the tests/fixtures
[   14s]         # dir. copy that fixtures dir to a temp dir and run _setup_py_from_dir
[   14s]         # PBR_VERSION is needed for the PBR tests because the fixture are not
[   14s]         # containing a git repo
[   14s]         monkeypatch.setenv("PBR_VERSION", "1")
[   14s]         fixture_dir = os.path.join(fixtures_base_dir, fixture_name)
[   14s]         dest_dir = os.path.join(tmpdir.strpath, fixture_name)
[   14s]         shutil.copytree(fixture_dir, dest_dir)
[   14s]         data = meta_utils._setup_py_run_from_dir(dest_dir, sys.executable)
[   14s]         for expected_key, expected_val in expected_data.items():
[   14s] >           assert expected_key in data['data']
[   14s] E           AssertionError: assert 'tests_require' in {'author': None, 'author_email': None, 'classifiers': [], 'contact': None, ...}
[   14s] 
[   14s] metaextract/tests/test_metaextract.py:251: AssertionError

Complete build log with the list of all packages used and steps taken to reproduce.

mcepl commented 2 months ago

I have no idea, how it could ever work, because those tests_require just aren’t in those setup.py files:

---
 metaextract/tests/test_metaextract.py |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/metaextract/tests/test_metaextract.py
+++ b/metaextract/tests/test_metaextract.py
@@ -147,7 +147,7 @@ class TestMetaExtract(object):
                 'entry_points': None, 'extras_require': {'extra1': ['pkg1']},
                 'install_requires': ['bar', 'foo'], 'python_requires': None,
                 'setup_requires': [], 'has_ext_modules': None,
-                'scripts': None, 'data_files': None, 'tests_require': None}
+                'scripts': None, 'data_files': None}
         ),
         (
             "setuptools_simple_unicode", {
@@ -155,14 +155,14 @@ class TestMetaExtract(object):
                     'extra1': ['pkg1'], 'extra2': ['pkg2', 'pkg3']},
                 'install_requires': ['bar', 'foo'], 'python_requires': None,
                 'setup_requires': [], 'has_ext_modules': None,
-                'scripts': None, 'data_files': None, 'tests_require': None}
+                'scripts': None, 'data_files': None}
         ),
         (
             "setuptools_simple_unicode_and_header", {
                 'entry_points': None, 'extras_require': {},
                 'install_requires': ['bar', 'foo'], 'python_requires': None,
                 'setup_requires': [], 'has_ext_modules': None,
-                'scripts': None, 'data_files': None, 'tests_require': None}
+                'scripts': None, 'data_files': None}
         ),
         (
             "setuptools_full", {
@@ -174,7 +174,7 @@ class TestMetaExtract(object):
                     ['share/doc/testpgk',
                      ['AUTHORS', 'LICENSE', 'README.rst']],
                     ['share/doc/testpkg/html', ['doc/testpkg.html']],
-                ], 'tests_require': ['testpkg1'], 'entry_points':
+                ], 'entry_points':
                 {
                     'console_scripts': ['testpkgp1=testpkg:main']
                 },
@@ -207,7 +207,6 @@ class TestMetaExtract(object):
              'extras_require': {}, 'install_requires': [],
              'python_requires': None, 'setup_requires': ['pbr>=1.0'],
              'has_ext_modules': None, 'scripts': None, 'data_files': None,
-             'tests_require': None,
              'version': '1'}
         ),
         (
toabctl commented 2 months ago

I can reproduce this with tox -epy3.

toabctl commented 2 months ago

downgrading the used setuptools to < 70 makes the tests pass again:

$ git diff               
diff --git a/test-requirements.txt b/test-requirements.txt
index d3726e6..72d6c10 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,4 +3,4 @@ pytest
 mock
 pbr
 Sphinx
-setuptools
+setuptools==69.1.1
toabctl commented 2 months ago

@mcepl I'll try to have a look next week (here's public holiday tomorrow and I won't be in front of a computer) if you've not found a solution.