Skip to content

Commit

Permalink
test: fix mocking _get_source_version in test_get_fixed_version
Browse files Browse the repository at this point in the history
mypy complains:

```
tests/integration/test_crashdb_launchpad.py:704: error: "Callable[[CrashDatabase, Any], Any]" has no attribute "return_value"  [attr-defined]
```
  • Loading branch information
bdrung committed Feb 14, 2025
1 parent ce03ae1 commit a6d71c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/integration/test_crashdb_launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,21 +692,23 @@ def test_update_traces_invalid(self) -> None:
r = self.crashdb.download(crash_id)
self.assertNotIn("CoreDump", r)

@unittest.mock.patch.object(CrashDatabase, "_get_source_version", MagicMock())
def test_get_fixed_version(self):
@unittest.mock.patch.object(CrashDatabase, "_get_source_version")
def test_get_fixed_version(self, get_source_version_mock: MagicMock) -> None:
"""get_fixed_version() for fixed bugs
Other cases are already checked in test_marking_segv() (invalid
bugs) and test_duplicates (duplicate bugs) for efficiency.
"""
# staging.launchpad.net often does not have Quantal, so mock-patch
# it to a known value
CrashDatabase._get_source_version.return_value = "3.14"
get_source_version_mock.return_value = "3.14"

Check warning on line 704 in tests/integration/test_crashdb_launchpad.py

View check run for this annotation

Codecov / codecov/patch

tests/integration/test_crashdb_launchpad.py#L704

Added line #L704 was not covered by tests
self._mark_report_fixed(self.get_segv_report())
fixed_ver = self.crashdb.get_fixed_version(self.get_segv_report())
self.assertEqual(fixed_ver, "3.14")
get_source_version_mock.assert_called_with("coreutils")

Check warning on line 708 in tests/integration/test_crashdb_launchpad.py

View check run for this annotation

Codecov / codecov/patch

tests/integration/test_crashdb_launchpad.py#L708

Added line #L708 was not covered by tests
self._mark_report_new(self.get_segv_report())
self.assertIsNone(self.crashdb.get_fixed_version(self.get_segv_report()))
get_source_version_mock.assert_called_with("coreutils")

Check warning on line 711 in tests/integration/test_crashdb_launchpad.py

View check run for this annotation

Codecov / codecov/patch

tests/integration/test_crashdb_launchpad.py#L711

Added line #L711 was not covered by tests

#
# Launchpad specific implementation and tests
Expand Down

0 comments on commit a6d71c9

Please sign in to comment.