Skip to content

test: relax check for Package field#592

Merged
bdrung merged 1 commit into
canonical:mainfrom
bdrung:fix-test-package
Apr 29, 2026
Merged

test: relax check for Package field#592
bdrung merged 1 commit into
canonical:mainfrom
bdrung:fix-test-package

Conversation

@bdrung
Copy link
Copy Markdown
Member

@bdrung bdrung commented Apr 22, 2026

test_run_report_bug_kernel_thread might failed in a autopkgtest VM:

=================================== FAILURES ===================================
_____________________ T.test_run_report_bug_kernel_thread ______________________

self = <tests.integration.test_ui.T testMethod=test_run_report_bug_kernel_thread>
get_version_mock = <MagicMock name='get_version' id='130971739753504'>

    @unittest.mock.patch("apport.packaging_impl.impl.get_version")
    def test_run_report_bug_kernel_thread(self, get_version_mock: MagicMock) -> None:
        """run_report_bug() for a pid of a kernel thread"""
        # The kernel package might not be installed in chroot environments.
        # Therefore mock get_version for the kernel package.
        get_version_mock.return_value = "5.15.0-33.34"

        for path in glob.glob("/proc/[0-9]*/stat"):
            with open(path, encoding="utf-8") as f:
                proc_stat = f.read().split()
            flags = int(proc_stat[8])
            if flags & apport.ui.PF_KTHREAD:
                pid = int(proc_stat[0])
                break
        else:
            self.skipTest("no kernel thread found")

        ui = UserInterfaceMock(["ui-test", "-f", "-P", str(pid)])
        ui.present_details_response = apport.ui.Action(report=True)
        ui.run_argv()
        assert ui.report

        kernel_package = packaging.get_kernel_package()
>       self.assertEqual(
            ui.report["Package"], f"{kernel_package} {get_version_mock.return_value}"
        )
E       AssertionError: 'linux-image-7.0.0-12-generic 5.15.0-33.34 [origin: unknown]' != 'linux-image-7.0.0-12-generic 5.15.0-33.34'
E       - linux-image-7.0.0-12-generic 5.15.0-33.34 [origin: unknown]
E       ?                                          ------------------
E       + linux-image-7.0.0-12-generic 5.15.0-33.34

tests/integration/test_ui.py:911: AssertionError
=============================== warnings summary ===============================

Bug: https://launchpad.net/bugs/2149909

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.54%. Comparing base (44389f4) to head (c21b7c6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #592   +/-   ##
=======================================
  Coverage   84.54%   84.54%           
=======================================
  Files         104      104           
  Lines       21028    21028           
  Branches     3221     3221           
=======================================
  Hits        17779    17779           
  Misses       2809     2809           
  Partials      440      440           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdrung bdrung force-pushed the fix-test-package branch from 609c33a to b439dcc Compare April 22, 2026 12:34
Copy link
Copy Markdown
Contributor

@Hyask Hyask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

`test_run_report_bug_kernel_thread` might failed in a autopkgtest VM:

```
=================================== FAILURES ===================================
_____________________ T.test_run_report_bug_kernel_thread ______________________

self = <tests.integration.test_ui.T testMethod=test_run_report_bug_kernel_thread>
get_version_mock = <MagicMock name='get_version' id='130971739753504'>

    @unittest.mock.patch("apport.packaging_impl.impl.get_version")
    def test_run_report_bug_kernel_thread(self, get_version_mock: MagicMock) -> None:
        """run_report_bug() for a pid of a kernel thread"""
        # The kernel package might not be installed in chroot environments.
        # Therefore mock get_version for the kernel package.
        get_version_mock.return_value = "5.15.0-33.34"

        for path in glob.glob("/proc/[0-9]*/stat"):
            with open(path, encoding="utf-8") as f:
                proc_stat = f.read().split()
            flags = int(proc_stat[8])
            if flags & apport.ui.PF_KTHREAD:
                pid = int(proc_stat[0])
                break
        else:
            self.skipTest("no kernel thread found")

        ui = UserInterfaceMock(["ui-test", "-f", "-P", str(pid)])
        ui.present_details_response = apport.ui.Action(report=True)
        ui.run_argv()
        assert ui.report

        kernel_package = packaging.get_kernel_package()
>       self.assertEqual(
            ui.report["Package"], f"{kernel_package} {get_version_mock.return_value}"
        )
E       AssertionError: 'linux-image-7.0.0-12-generic 5.15.0-33.34 [origin: unknown]' != 'linux-image-7.0.0-12-generic 5.15.0-33.34'
E       - linux-image-7.0.0-12-generic 5.15.0-33.34 [origin: unknown]
E       ?                                          ------------------
E       + linux-image-7.0.0-12-generic 5.15.0-33.34

tests/integration/test_ui.py:911: AssertionError
=============================== warnings summary ===============================
```

Bug: https://launchpad.net/bugs/2149909
@bdrung bdrung force-pushed the fix-test-package branch from b439dcc to c21b7c6 Compare April 29, 2026 15:06
@bdrung
Copy link
Copy Markdown
Member Author

bdrung commented Apr 29, 2026

Just rebased.

@bdrung bdrung merged commit c21b7c6 into canonical:main Apr 29, 2026
19 checks passed
@bdrung bdrung deleted the fix-test-package branch April 29, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants