switch test_signatures.py to mkdtemp to fix mystery

I have no idea what is causing this to fail, but the mkdtemp pattern used
in other test files seems to fix it.

https://gitlab.com/fdroid/fdroidserver/-/jobs/11776468083
======================================================================
ERROR: test_main (tests.test_signatures.SignaturesTest.test_main)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/fdroid/fdroidserver/tests/test_signatures.py", line 28, in test_main
    with TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
                                         ^^^^^^^^^^^^^^
  File "/builds/fdroid/fdroidserver/tests/shared_test_code.py", line 44, in __enter__
    self.orig_cwd = os.getcwd()
                    ^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory
----------------------------------------------------------------------
This commit is contained in:
Hans-Christoph Steiner 2025-10-21 10:24:22 +02:00
parent 2fbd6f1a19
commit 4f1b50f7a6

View file

@ -4,28 +4,34 @@ import hashlib
import os
import sys
import unittest
from tempfile import TemporaryDirectory
from fdroidserver import common, signatures
from .shared_test_code import TmpCwd
from .shared_test_code import mkdtemp
basedir = os.path.dirname(__file__)
class SignaturesTest(unittest.TestCase):
def setUp(self):
self._td = mkdtemp()
self.testdir = self._td.name
os.chdir(self.testdir)
common.config = None
config = common.read_config()
config['jarsigner'] = common.find_sdk_tools_cmd('jarsigner')
common.config = config
def tearDown(self):
self._td.cleanup()
common.config = None
@unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
def test_main(self):
class OptionsFixture:
APK = [os.path.join(basedir, 'repo', 'com.politedroid_3.apk')]
with TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
signatures.extract(OptionsFixture)
# check if extracted signatures are where they are supposed to be