Bug 2273343 - python-pytest-postgresql fails to build with pytest 8: TypeError: 'NoneType' object is not iterable
Summary: python-pytest-postgresql fails to build with pytest 8: TypeError: 'NoneType' ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pytest-postgresql
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mikel Olasagasti Uranga
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-04-04 10:50 UTC by Tomáš Hrnčiar
Modified: 2024-04-05 12:25 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-04-05 10:12:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2024-04-04 10:50:03 UTC
python-pytest-postgresql fails to build with pytest 8.

==================================== ERRORS ====================================
___________________ ERROR at setup of test_postgres_options ____________________

request = <SubRequest 'postgresql' for <Function test_postgres_options>>

    @pytest.fixture
    def postgresql_factory(request: FixtureRequest) -> Iterator[connection]:
        """
        Fixture factory for PostgreSQL.
    
        :param request: fixture request object
        :returns: postgresql client
        """
        check_for_psycopg()
>       proc_fixture: Union[PostgreSQLExecutor, NoopExecutor] = request.getfixturevalue(
            process_fixture_name
        )

/builddir/build/BUILDROOT/python-pytest-postgresql-4.1.1-5.fc41.x86_64/usr/lib/python3.12/site-packages/pytest_postgresql/factories/client.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

request = <SubRequest 'postgresql_proc' for <Function test_postgres_options>>
tmp_path_factory = TempPathFactory(_given_basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0/basetemp'), _trace=<pluggy._tracing.TagTr...c0980>, _basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0/basetemp'), _retention_count=3, _retention_policy='all')

    @pytest.fixture(scope="session")
    def postgresql_proc_fixture(
        request: FixtureRequest, tmp_path_factory: TempPathFactory
    ) -> Iterator[PostgreSQLExecutor]:
        """
        Process fixture for PostgreSQL.
    
        :param request: fixture request object
        :param tmp_path_factory: temporary path object (fixture)
        :returns: tcp executor
        """
        config = get_config(request)
        postgresql_ctl = executable or config["exec"]
        logfile_prefix = logs_prefix or config["logsprefix"]
        pg_dbname = dbname or config["dbname"]
        pg_load = load or config["load"]
    
        # check if that executable exists, as it's no on system PATH
        # only replace if executable isn't passed manually
        if not os.path.exists(postgresql_ctl) and executable is None:
            pg_bindir = subprocess.check_output(
                ["pg_config", "--bindir"], universal_newlines=True
            ).strip()
            postgresql_ctl = os.path.join(pg_bindir, "pg_ctl")
    
        tmpdir = tmp_path_factory.mktemp(f"pytest-postgresql-{request.fixturename}")
    
        if logfile_prefix:
            warn(
                f"logfile_prefix and logsprefix config option is deprecated, "
                f"and will be dropped in future releases. All fixture related "
                f"data resides within {tmpdir}",
                DeprecationWarning,
            )
    
        pg_port = get_port(port) or get_port(config["port"])
        assert pg_port is not None
        datadir = tmpdir / f"data-{pg_port}"
        datadir.mkdir()
        logfile_path = tmpdir / f"{logfile_prefix}postgresql.{pg_port}.log"
    
        if platform.system() == "FreeBSD":
            with (datadir / "pg_hba.conf").open(mode="a") as conf_file:
                conf_file.write("host all all 0.0.0.0/0 trust\n")
    
        postgresql_executor = PostgreSQLExecutor(
            executable=postgresql_ctl,
            host=host or config["host"],
            port=pg_port,
            user=user or config["user"],
            password=password or config["password"],
            dbname=pg_dbname,
            options=options or config["options"],
            datadir=str(datadir),
            unixsocketdir=unixsocketdir or config["unixsocketdir"],
            logfile=str(logfile_path),
            startparams=startparams or config["startparams"],
            postgres_options=postgres_options or config["postgres_options"],
        )
        # start server
        with postgresql_executor:
            postgresql_executor.wait_for_postgres()
            template_dbname = f"{postgresql_executor.dbname}_tmpl"
            with DatabaseJanitor(
                user=postgresql_executor.user,
                host=postgresql_executor.host,
                port=postgresql_executor.port,
                dbname=template_dbname,
                version=postgresql_executor.version,
                password=postgresql_executor.password,
            ) as janitor:
>               for load_element in pg_load:
E               TypeError: 'NoneType' object is not iterable

=========================== short test summary info ============================
FAILED tests/test_postgres_options_plugin.py::test_postgres_options_config_in_cli
FAILED tests/test_postgres_options_plugin.py::test_postgres_options_config_in_ini
ERROR tests/test_executor.py::test_proc_with_password - TypeError: 'NoneType'...
ERROR tests/test_executor.py::test_postgres_options - TypeError: 'NoneType' o...
ERROR tests/test_executor.py::test_custom_isolation_level - TypeError: 'NoneT...
ERROR tests/test_noopexecutor.py::test_noproc_version - TypeError: 'NoneType'...
ERROR tests/test_noopexecutor.py::test_noproc_cached_version - TypeError: 'No...
ERROR tests/test_postgresql.py::test_postgresql_proc - TypeError: 'NoneType' ...
ERROR tests/test_postgresql.py::test_main_postgres - TypeError: 'NoneType' ob...
ERROR tests/test_postgresql.py::test_two_postgreses - TypeError: 'NoneType' o...
ERROR tests/test_postgresql.py::test_postgres_load_one_file - TypeError: 'Non...
ERROR tests/test_postgresql.py::test_postgres_load_two_files - TypeError: 'No...
ERROR tests/test_postgresql.py::test_rand_postgres_port - TypeError: 'NoneTyp...
ERROR tests/test_postgresql.py::test_postgres_terminate_connection[0] - TypeE...
ERROR tests/test_postgresql.py::test_postgres_terminate_connection[1] - TypeE...
====== 2 failed, 20 passed, 6 deselected, 22 warnings, 13 errors in 5.65s ======

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07248721-python-pytest-postgresql/

For all our attempts to build python-pytest-postgresql with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/python-pytest-postgresql/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. And this bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change
proposal https://fedoraproject.org/wiki/Changes/Pytest_8

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Mikel Olasagasti Uranga 2024-04-04 10:56:02 UTC
4.1.1 fails with those errors, but since 5.0.0 there is another issue that blocks the update. I reported to python-devel list as I'm not sure how to fix this.

https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/V4P5UWBNCGGM27O55RQUHJE2K3UIJ44I/

I see you already tried in COPR with 6.0.0 https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/python-pytest-postgresql/

Comment 2 Mikel Olasagasti Uranga 2024-04-05 10:12:37 UTC
Updated to 6.0.0 and latest build seems to work with pytest-8.1.1

https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/build/7265685/

Comment 3 Tomáš Hrnčiar 2024-04-05 12:25:54 UTC
Thank you for coming up with a solution! I was looking into it yesterday but couldn't figure out how to make it build.


Note You need to log in before you can comment on or make changes to this bug.