commit:     7c75dd616afa8db25254aa34928360e9549b6e35
Author:     Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com>
AuthorDate: Sat Apr  1 20:10:20 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Apr  2 19:17:09 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7c75dd61

tests: fix util/test_shelve.py

Remove the `os.unlink()` call which can fail if the backend lib, eg,
adds a suffix to the filename. When debugging this failed run [1], the
`shelve_file` was being created as `shelve_file.db`.

>From the Python docs:

    The filename parameter is the base filename for the underlying
    database.  As a side-effect, an extension may be added to the
    filename and more than one file may be created.

Test failure:

ERROR: test_dump_restore (portage.tests.util.test_shelve.ShelveUtilsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/build/portage/build/lib/portage/tests/__init__.py", line 274, in 
run
    testMethod()
  File "/home/build/portage/build/lib/portage/tests/util/test_shelve.py", line 
47, in test_dump_restore
    os.unlink(dump_args.src)
FileNotFoundError: [Errno 2] No such file or directory: 
'/tmp/tmpjq543rhp/shelve_file'

[1]: https://builds.sr.ht/~xxc3nsoredxx/job/966549

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1017
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                  | 3 ++-
 lib/portage/tests/util/test_shelve.py | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 01209c9fb..663d757e2 100644
--- a/NEWS
+++ b/NEWS
@@ -56,7 +56,8 @@ Features:
   for a time for compatibility.
 
 Bug fixes:
-* TODO
+* tests: util/test_shelve: fix test failure if the backend for the shelve 
module
+  does not create the shelve db using the literal filename.
 
 portage-3.0.45.3 (2023-03-19)
 ----------------

diff --git a/lib/portage/tests/util/test_shelve.py 
b/lib/portage/tests/util/test_shelve.py
index 1e532db77..b1759ed5f 100644
--- a/lib/portage/tests/util/test_shelve.py
+++ b/lib/portage/tests/util/test_shelve.py
@@ -1,4 +1,4 @@
-# Copyright 2020-2021 Gentoo Authors
+# Copyright 2020-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import argparse
@@ -44,7 +44,6 @@ class ShelveUtilsTestCase(TestCase):
                 db.close()
                 dump(dump_args)
 
-                os.unlink(dump_args.src)
                 restore_args = argparse.Namespace(
                     dest=dump_args.src,
                     src=dump_args.dest,

Reply via email to