con / duct

A helper to run a command, capture stdout/stderr and details about running
https://pypi.org/project/con-duct/
MIT License
4 stars 2 forks source link

test_system_info_sanity fails due to .uid being None while building debian package #194

Closed yarikoptic closed 1 month ago

yarikoptic commented 1 month ago

may be some sanitization is done by debian tools to make build independent of user, but yet to check

meanwhile here is how it looks:

running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/con_duct
copying build/lib/con_duct/__init__.py -> build/bdist.linux-x86_64/wheel/con_duct
copying build/lib/con_duct/__main__.py -> build/bdist.linux-x86_64/wheel/con_duct
copying build/lib/con_duct/py.typed -> build/bdist.linux-x86_64/wheel/con_duct
running install_egg_info
Copying src/con_duct.egg-info to build/bdist.linux-x86_64/wheel/con_duct-0.4.0.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/con_duct-0.4.0.dist-info/WHEEL
creating '/home/yoh/deb/gits/build-area/con-duct-0.4.0/.pybuild/cpython3_3.12_con-duct/.tmp-wrik7x60/con_duct-0.4.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'con_duct/__init__.py'
adding 'con_duct/__main__.py'
adding 'con_duct/py.typed'
adding 'con_duct-0.4.0.dist-info/LICENSE'
adding 'con_duct-0.4.0.dist-info/METADATA'
adding 'con_duct-0.4.0.dist-info/WHEEL'
adding 'con_duct-0.4.0.dist-info/entry_points.txt'
adding 'con_duct-0.4.0.dist-info/top_level.txt'
adding 'con_duct-0.4.0.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Successfully built con_duct-0.4.0-py3-none-any.whl
I: pybuild plugin_pyproject:144: Unpacking wheel built for python3.12 with "installer" module
   dh_auto_test -O--buildsystem=pybuild
I: pybuild base:311: cd /home/yoh/deb/gits/build-area/con-duct-0.4.0/.pybuild/cpython3_3.12_con-duct/build; python3.12 -m pytest test
============================= test session starts ==============================
platform linux -- Python 3.12.5, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/yoh/deb/gits/build-area/con-duct-0.4.0
configfile: tox.ini
plugins: timeout-2.3.1, cov-5.0.0, mock-3.14.0, anyio-4.4.0
collected 161 items

test/test_aggregation.py ..............                                  [  8%]
test/test_arg_parsing.py ......                                          [ 12%]
test/test_execution.py ..............                                    [ 21%]
test/test_formatter.py .............................................     [ 49%]
test/test_log_paths.py ..............                                    [ 57%]
test/test_prepare_outputs.py ................                            [ 67%]
test/test_report.py ....................F...                             [ 82%]
test/test_tailpipe.py ...............                                    [ 91%]
test/test_validation.py .............                                    [100%]

=================================== FAILURES ===================================
___________________________ test_system_info_sanity ____________________________

mock_log_paths = <MagicMock name='LogPaths' id='140592236407280'>

    @mock.patch("con_duct.__main__.LogPaths")
    def test_system_info_sanity(mock_log_paths: mock.MagicMock) -> None:
        mock_log_paths.prefix = "mock_prefix"
        report = Report("_cmd", [], mock_log_paths, EXECUTION_SUMMARY_FORMAT, clobber=False)
        report.get_system_info()
        assert report.system_info is not None
        assert report.system_info.hostname
        assert report.system_info.cpu_total
        assert report.system_info.memory_total > 10
>       assert report.system_info.uid
E       AssertionError: assert None
E        +  where None = SystemInfo(uid=None, memory_total=67080265728, cpu_total=20, hostname='bilena').uid
E        +    where SystemInfo(uid=None, memory_total=67080265728, cpu_total=20, hostname='bilena') = <con_duct.__main__.Report object at 0x7fde2e4f34a0>.system_info

test/test_report.py:196: AssertionError
=========================== short test summary info ============================
FAILED test/test_report.py::test_system_info_sanity - AssertionError: assert ...
======================== 1 failed, 160 passed in 13.45s ========================
E: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /home/yoh/deb/gits/build-area/con-duct-0.4.0/.pybuild/cpython3_3.12_con-duct/build; python3.12 -m pytest test
dh_auto_test: error: pybuild --test --test-pytest -i python{version} -p 3.12 returned exit code 13
make: *** [debian/rules:5: binary] Error 25
yarikoptic commented 1 month ago

reproduction is easy - just unset USER:

❯ (unset USER; python3.12 -m pytest -k test_system_info_sanity test )
=============================================================================== test session starts ================================================================================
platform linux -- Python 3.12.5, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/yoh/proj/CON/duct
configfile: tox.ini
plugins: mock-3.14.0, cov-5.0.0, xdist-3.6.1
collected 162 items / 161 deselected / 1 selected                                                                                                                                  

test/test_report.py F                                                                                                                                                        [100%]

===================================================================================== FAILURES =====================================================================================
_____________________________________________________________________________ test_system_info_sanity ______________________________________________________________________________

mock_log_paths = <MagicMock name='LogPaths' id='140496362021872'>

    @mock.patch("con_duct.__main__.LogPaths")
    def test_system_info_sanity(mock_log_paths: mock.MagicMock) -> None:
        mock_log_paths.prefix = "mock_prefix"
        report = Report("_cmd", [], mock_log_paths, EXECUTION_SUMMARY_FORMAT, clobber=False)
        report.get_system_info()
        assert report.system_info is not None
        assert report.system_info.hostname
        assert report.system_info.cpu_total
        assert report.system_info.memory_total > 10
>       assert report.system_info.uid
E       AssertionError: assert None
E        +  where None = SystemInfo(uid=None, memory_total=67080265728, cpu_total=20, hostname='bilena').uid
E        +    where SystemInfo(uid=None, memory_total=67080265728, cpu_total=20, hostname='bilena') = <con_duct.__main__.Report object at 0x7fc7dbc034a0>.system_info

test/test_report.py:196: AssertionError
============================================================================= short test summary info ==============================================================================
FAILED test/test_report.py::test_system_info_sanity - AssertionError: assert None
======================================================================== 1 failed, 161 deselected in 2.08s

I will submit a quick fix