[Piuparts-devel] [Git][debian/piuparts][develop] tests: Update unittest asserts to non-deprecated versions

Nicolas Dandrimont (@olasd) gitlab at salsa.debian.org
Fri Mar 15 10:16:10 GMT 2024



Nicolas Dandrimont pushed to branch develop at Debian / piuparts


Commits:
04e2c7d4 by Nicolas Dandrimont at 2024-03-15T11:15:12+01:00
tests: Update unittest asserts to non-deprecated versions

Closes: #1061749

- - - - -


4 changed files:

- tests/test_dependencyparser.py
- tests/test_piuparts.py
- tests/test_pkgsummary.py
- tests/unittests.py


Changes:

=====================================
tests/test_dependencyparser.py
=====================================
@@ -18,16 +18,16 @@ class DependencyParserTests(unittest.TestCase):
 
     def testEmpty(self):
         deps, names = self.parse("")
-        self.failUnlessEqual(deps, [])
+        self.assertEqual(deps, [])
 
     def testSingle(self):
         deps, names = self.parse("foo")
-        self.failUnlessEqual(names, [["foo"]])
+        self.assertEqual(names, [["foo"]])
 
     def testTwo(self):
         deps, names = self.parse("foo, bar")
-        self.failUnlessEqual(names, [["foo"], ["bar"]])
+        self.assertEqual(names, [["foo"], ["bar"]])
 
     def testAlternatives(self):
         deps, names = self.parse("foo, bar | foobar")
-        self.failUnlessEqual(names, [["foo"], ["bar", "foobar"]])
+        self.assertEqual(names, [["foo"], ["bar", "foobar"]])


=====================================
tests/test_piuparts.py
=====================================
@@ -102,51 +102,51 @@ class IsBrokenSymlinkTests(unittest.TestCase):
         shutil.rmtree(self.testdir)
 
     def testRelativeBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "relative-broken"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "relative-broken"))
 
     def testRelativeBrokenToSymlink(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "relative-broken-to-symlink"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "relative-broken-to-symlink"))
 
     def testAbsoluteBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "absolute-broken"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "absolute-broken"))
 
     def testAbsoluteBrokenToSymlink(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "absolute-broken-to-symlink"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "absolute-broken-to-symlink"))
 
     def testTrailingSlashBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "trailing-slash-broken"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "trailing-slash-broken"))
 
     def testSelfLoopBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "selfloop"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "selfloop"))
 
     def testExpandingSelfLoopBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "explode"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "explode"))
 
     def testAbsoluteSelfLoopBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "absolute-selfloop"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "absolute-selfloop"))
 
     def testSubdirSelfLoopBroken(self):
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/selfloop"))
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/selfloop1"))
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop"))
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop1"))
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop2"))
-        self.failUnless(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop3"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/selfloop"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/selfloop1"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop1"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop2"))
+        self.assertTrue(is_broken_symlink(self.testdir, self.testdir, "dir/subdir/selfloop3"))
 
     def testRelativeWorks(self):
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "relative-works"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "relative-works"))
 
     def testRelativeWorksToSymlink(self):
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "relative-works-to-symlink"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "relative-works-to-symlink"))
 
     def testAbsoluteWorks(self):
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "absolute-works"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "absolute-works"))
 
     def testAbsoluteWorksToSymlink(self):
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "absolute-works-to-symlink"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "absolute-works-to-symlink"))
 
     def testTrailingSlashWorks(self):
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "trailing-slash-works"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "trailing-slash-works"))
 
     def testMultiLevelNestedSymlinks(self):
         # target/first-link -> ../target/second-link -> ../target
@@ -154,7 +154,7 @@ class IsBrokenSymlinkTests(unittest.TestCase):
         os.mkdir(os.path.join(self.testdir, "target"))
         self.symlink("../target", "target/second-link")
         self.symlink("../target/second-link", "target/first-link")
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "target/first-link"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "target/first-link"))
 
     def testMultiLevelNestedAbsoluteSymlinks(self):
         # first-link -> /second-link/final-target
@@ -164,4 +164,4 @@ class IsBrokenSymlinkTests(unittest.TestCase):
         os.mkdir(os.path.join(self.testdir, "final-dir/final-target"))
         self.symlink("/second-link/final-target", "first-link")
         self.symlink("/final-dir", "second-link")
-        self.failIf(is_broken_symlink(self.testdir, self.testdir, "first-link"))
+        self.assertFalse(is_broken_symlink(self.testdir, self.testdir, "first-link"))


=====================================
tests/test_pkgsummary.py
=====================================
@@ -14,7 +14,7 @@ class PkgSummaryTests(unittest.TestCase):
         states = sorted([y for x in finfo for y in finfo[x].states])
         nodups = sorted(list(set(states)))
 
-        self.assertTrue("successfully-tested" in states)
+        self.assertIn("successfully-tested", states)
         self.assertEqual(states, nodups)
 
     def testSummGetFlag(self):
@@ -93,7 +93,7 @@ class PkgSummaryAddTests(unittest.TestCase):
     def testSummAddInvalid(self):
         pkgsummary.add_summary(self.summ, "dist", "pkg", "-", 0, "http://foo")
         print(self.summ["packages"]["pkg"]["dist"][2])
-        self.assertTrue("http" in self.summ["packages"]["pkg"]["dist"][2])
+        self.assertIn("http", self.summ["packages"]["pkg"]["dist"][2])
 
     def testSummMerge(self):
         pkgsummary.add_summary(self.summ, "dist", "pkg", "X", 0, "http://foo")


=====================================
tests/unittests.py
=====================================
@@ -54,7 +54,7 @@ class PackagesDbTests(unittest.TestCase):
 
     def testNoPackages(self):
         p = self.reserve("")
-        self.failUnlessEqual(p, None)
+        self.assertEqual(p, None)
 
     def testNoDeps(self):
         p = self.reserve(
@@ -63,8 +63,8 @@ Package: foo
 Version: 1.0-1
 """
         )
-        self.failIfEqual(p, None)
-        self.failUnlessEqual(p["Package"], "foo")
+        self.assertNotEqual(p, None)
+        self.assertEqual(p["Package"], "foo")
 
 
 if __name__ == "__main__":



View it on GitLab: https://salsa.debian.org/debian/piuparts/-/commit/04e2c7d426b8c1680eaf37ed3af137023ad5e942

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/commit/04e2c7d426b8c1680eaf37ed3af137023ad5e942
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20240315/df199b3d/attachment-0001.htm>


More information about the Piuparts-devel mailing list