Repository: spoorn/poeblix (language: python)

Issue:
Test fails with Python 3.11
The `test_positive_with_groups` fails under Python 3.11 as 2 dependencies (`exceptiongroup` and `tomli`) are only included in Python <= 3.10.

```
❯ pytest test_walkthrough.py 
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.2.0 -- /home/user/code/poeblix/venv311/bin/python
cachedir: .pytest_cache
rootdir: /home/user/code/poeblix
configfile: pyproject.toml
plugins: pspec-0.0.4, cov-4.1.0
collected 9 items                                                                                                                                                                                                                            

test_walkthrough.py::::test_positive_happy_case_example PASSED                                                                                                                                                                         [ 11%]
test_walkthrough.py::::test_positive_with_groups FAILED                                                                                                                                                                                [ 22%]
test_walkthrough.py::::test_positive_no_lock PASSED                                                                                                                                                                                    [ 33%]
test_walkthrough.py::::test_positive_only_lock PASSED                                                                                                                                                                                  [ 44%]
test_walkthrough.py::::test_negative_incompatible_lock_options PASSED                                                                                                                                                                  [ 55%]
test_walkthrough.py::::test_negative_missing_from_project PASSED                                                                                                                                                                       [ 66%]
test_walkthrough.py::::test_negative_missing_from_wheel PASSED                                                                                                                                                                         [ 77%]
test_walkthrough.py::::test_negative_missing_data_files PASSED                                                                                                                                                                         [ 88%]
test_walkthrough.py::::test_negative_missing_data_files_from_project PASSED                                                                                                                                                            [100%]/home/user/code/poeblix/venv311/lib/python3.11/site-packages/coverage/inorout.py:507: CoverageWarning: Module poeblix was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/coverage/control.py:883: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")


================================================================================================================== FAILURES ==================================================================================================================
_________________________________________________________________________________________________________ test_positive_with_groups __________________________________________________________________________________________________________

    def test_positive_with_groups():
        cwd = "positive_cases/happy_case_example"
        # Build
        subprocess.check_call(["poetry", "blixbuild", "--with-groups=integ,dev", "-vvv"], cwd=cwd)
    
        # Validate wheel
        subprocess.check_call(
            ["poetry", "blixvalidatewheel", "--with-groups=integ,dev", "dist/blixexample-0.1.0-py3-none-any.whl"], cwd=cwd
        )
    
        path = os.path.join(cwd, "dist/blixexample-0.1.0-py3-none-any.whl")
        metadata = pkginfo.get_metadata(path)
    
        # Validate wheel metadata
        expected = {
            "SQLAlchemy (==2.0.15)",
            "greenlet (==2.0.2)",
            'gunicorn (>=19.9.0,<20.0.0) ; extra == "gunicorn"',
            "nemoize (>=0.1.0,<0.2.0)",
            "numpy (==1.24.3)",
            "pandas (==1.4.2)",
            "python-dateutil (==2.8.2)",
            "six (==1.16.0)",
            "flake8 (==4.0.1)",
            "iniconfig (==2.0.0)",
            "mccabe (==0.6.1)",
            "packaging (==23.1)",
            "pluggy (==1.0.0)",
            "pycodestyle (==2.8.0)",
            "pyflakes (==2.4.0)",
            "exceptiongroup (==1.1.1)",
            "pytest (==7.3.1)",
            "pytz (==2023.3)",
            "tomli (==2.0.1)",
            "typing-extensions (==4.6.2)",
        }
    
        # These dependencies are only on Windows
        if os.name == "nt":
            expected.add("colorama (==0.4.6)")
    
        missing = []
        for package in metadata.requires_dist:
            if package in expected:
                expected.remove(package)
            else:
                missing.append(package)
    
        assert len(missing) == 0, f"{missing} packages were not in expected {expected}"
>       assert len(expected) == 0, f"Wheel is missing Required-Dist: {expected}"
E       AssertionError: Wheel is missing Required-Dist: {'tomli (==2.0.1)', 'exceptiongroup (==1.1.1)'}
E       assert 2 == 0
E        +  where 2 = len({'exceptiongroup (==1.1.1)', 'tomli (==2.0.1)'})

test_walkthrough.py:91: AssertionError
------------------------------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------------------------------
Using virtualenv: /home/user/code/poeblix/venv311
Building blixexample (0.1.0)
Adding data_files=[{'destination': 'share/data/', 'from': ['data_files/test.txt', 'data_files/anotherfile']}, {'destination': 'share/data/threes', 'from': ['data_files/athirdfile']}]
  - Building wheel
Ignoring: 
  - Adding: /home/user/code/poeblix/test/positive_cases/happy_case_example/src/blixexample/__init__.py
  - Adding: /home/user/code/poeblix/test/positive_cases/happy_case_example/src/blixexample/main.py
Adding dependencies from lock file to wheel build
Resolving dependencies using poetry's solver to get rid of unneeded packages
Adding resolved dependencies to wheel METADATA
Adding to Wheel Requires Dist: [<Install greenlet (2.0.2)>, <Update mccabe (0.7.0) to mccabe (0.6.1)>, <Install numpy (1.24.3)>, <Update packaging (23.2) to packaging (23.1)>, <Update pluggy (1.3.0) to pluggy (1.0.0)>, <Update pycodestyle (2.11.1) to pycodestyle (2.8.0)>, <Update pyflakes (3.1.0) to pyflakes (2.4.0)>, <Install python-dateutil (2.8.2)>, <Install pytz (2023.3)>, <Update typing_extensions (4.8.0) to typing-extensions (4.6.2)>, <Update flake8 (6.1.0) to flake8 (4.0.1)>, <Install gunicorn (19.10.0)>, <Install iniconfig (2.0.0)>, <Install nemoize (0.1.0)>, <Install pandas (1.4.2)>, <Update pytest (7.4.3) to pytest (7.3.1)>, <Install six (1.16.0)>, <Install sqlalchemy (2.0.15)>]
Skipping: /home/user/code/poeblix/test/positive_cases/happy_case_example/COPYING
Skipping: /home/user/code/poeblix/test/positive_cases/happy_case_example/LICENSE
Adding data_files to WHEEL data folder
Copying data files from /home/user/code/poeblix/test/positive_cases/happy_case_example/data_files/test.txt to /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/test.txt
Copying data files from /home/user/code/poeblix/test/positive_cases/happy_case_example/data_files/anotherfile to /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/anotherfile
Copying data files from /home/user/code/poeblix/test/positive_cases/happy_case_example/data_files/athirdfile to /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/threes/athirdfile
Copying file from /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/anotherfile to wheel relative blixexample-0.1.0.data/data/share/data/anotherfile
Copying file from /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/test.txt to wheel relative blixexample-0.1.0.data/data/share/data/test.txt
Copying file from /tmp/tmp2fudle84/blixexample-0.1.0.data/data/share/data/threes/athirdfile to wheel relative blixexample-0.1.0.data/data/share/data/threes/athirdfile
  - Built blixexample-0.1.0-py3-none-any.whl
Validating Requires Dist for wheel [dist/blixexample-0.1.0-py3-none-any.whl] against pyproject.toml/poetry.lock
Validating against pyproject.toml...
Validating against poetry.lock...
Validating data_files in wheel file contain those specified in pyproject.toml
Validation succeeded!

---------- coverage: platform linux, python 3.11.5-final-0 -----------
Name                                                                                        Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------------------------------------------------------------------------------------------
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/__init__.py             0      0      0      0   100%
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/plugins.py            121      5     44      6    93%   67, 70, 158->184, 165, 244->256, 252-253, 284->exit
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/util/__init__.py        0      0      0      0   100%
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/util/util.py           30      0     10      2    95%   28->27, 32->34
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/validatedocker.py      50     33     18      0    25%   49-58, 64-82, 88-106
/home/user/code/poeblix/venv311/lib/python3.11/site-packages/poeblix/validatewheel.py      110      6     48      5    93%   17-18, 78->102, 122, 155, 168, 177
---------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                         311     44    120     13    83%

Required test coverage of 80% reached. Total coverage: 82.60%
========================================================================================================== short test summary info ===========================================================================================================
FAILED test_walkthrough.py::::test_positive_with_groups - AssertionError: Wheel is missing Required-Dist: {'tomli (==2.0.1)', 'exceptiongroup (==1.1.1)'}
======================================================================================================== 1 failed, 8 passed in 21.26s ========================================================================================================

```


Discussion / hints:

Fix patch:
diff --git a/devtool b/devtool
index c4f6b84..1fcd8d2 100755
--- a/devtool
+++ b/devtool
@@ -41,8 +41,8 @@ test() {
   PY_VERSION=$(python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))')
 
   # Walkthrough tests
-  if [[ $PY_VERSION == "3.9" ]]; then
-    echo "== Python 3.9 Walkthrough Tests =="
+  if [[ $PY_VERSION =~ ^3\.(9|10|11)$ ]]; then
+    echo "== Python >= 3.9 Walkthrough Tests =="
     cd test && pytest --pspec test_walkthrough.py ; cd -
   elif [[ $PY_VERSION == "3.8" ]]; then
     echo "== Python 3.8 Walkthrough Tests =="


Test patch:
diff --git a/test/test_walkthrough.py b/test/test_walkthrough.py
index 2ee870a..0169b4c 100644
--- a/test/test_walkthrough.py
+++ b/test/test_walkthrough.py
@@ -1,5 +1,6 @@
 import os.path
 import subprocess
+import sys
 
 import pkginfo
 
@@ -69,13 +70,16 @@ def test_positive_with_groups():
         "pluggy (==1.0.0)",
         "pycodestyle (==2.8.0)",
         "pyflakes (==2.4.0)",
-        "exceptiongroup (==1.1.1)",
         "pytest (==7.3.1)",
         "pytz (==2023.3)",
-        "tomli (==2.0.1)",
         "typing-extensions (==4.6.2)",
     }
 
+    # These dependencies are only on Python < 3.11
+    if sys.version_info.major == 3 and sys.version_info.minor < 11:
+        expected.add("exceptiongroup (==1.1.1)")
+        expected.add("tomli (==2.0.1)")
+
     # These dependencies are only on Windows
     if os.name == "nt":
         expected.add("colorama (==0.4.6)")