commit:     b7bd20a83676fa29ac92a9790cee84c68148beb0
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 16 08:02:14 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Feb 18 10:13:35 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b7bd20a8

tests: news: add failing Display-If-Installed test

This shows that our current Display-If-Installed test
doesn't work properly, as it'll pass with any package
value.

Bug: https://bugs.gentoo.org/889330
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/tests/news/test_NewsItem.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/portage/tests/news/test_NewsItem.py 
b/lib/portage/tests/news/test_NewsItem.py
index ba9fa0035..9324a7d18 100644
--- a/lib/portage/tests/news/test_NewsItem.py
+++ b/lib/portage/tests/news/test_NewsItem.py
@@ -170,6 +170,18 @@ class NewsItemTestCase(TestCase):
         finally:
             os.unlink(item.path)
 
+        tmpItem = self._createNewsItem({"display_if_installed": 
["sys-apps/i-do-not-exist"]})
+
+        try:
+            item = self._processItem(str(tmpItem))
+            self.assertTrue(item.isValid())
+            self.assertFalse(
+                item.isRelevant(self.vardb, self.settings, self.profile),
+                msg=f"Expected {tmpItem} to be irrelevant, but it was 
relevant!",
+            )
+        finally:
+            os.unlink(item.path)
+
     def testDisplayIfKeyword(self):
         tmpItem = self._createNewsItem({"display_if_keyword": [self.keywords]})
 

Reply via email to