mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	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:
		
							parent
							
								
									2fbd6f1a19
								
							
						
					
					
						commit
						4f1b50f7a6
					
				
					 1 changed files with 35 additions and 29 deletions
				
			
		| 
						 | 
					@ -4,56 +4,62 @@ import hashlib
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from tempfile import TemporaryDirectory
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from fdroidserver import common, signatures
 | 
					from fdroidserver import common, signatures
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .shared_test_code import TmpCwd
 | 
					from .shared_test_code import mkdtemp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
basedir = os.path.dirname(__file__)
 | 
					basedir = os.path.dirname(__file__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SignaturesTest(unittest.TestCase):
 | 
					class SignaturesTest(unittest.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
 | 
					        self._td = mkdtemp()
 | 
				
			||||||
 | 
					        self.testdir = self._td.name
 | 
				
			||||||
 | 
					        os.chdir(self.testdir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        common.config = None
 | 
					        common.config = None
 | 
				
			||||||
        config = common.read_config()
 | 
					        config = common.read_config()
 | 
				
			||||||
        config['jarsigner'] = common.find_sdk_tools_cmd('jarsigner')
 | 
					        config['jarsigner'] = common.find_sdk_tools_cmd('jarsigner')
 | 
				
			||||||
        common.config = config
 | 
					        common.config = config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def tearDown(self):
 | 
				
			||||||
 | 
					        self._td.cleanup()
 | 
				
			||||||
 | 
					        common.config = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
 | 
					    @unittest.skipIf(sys.byteorder == 'big', "androguard is not ported to big-endian")
 | 
				
			||||||
    def test_main(self):
 | 
					    def test_main(self):
 | 
				
			||||||
        class OptionsFixture:
 | 
					        class OptionsFixture:
 | 
				
			||||||
            APK = [os.path.join(basedir, 'repo', 'com.politedroid_3.apk')]
 | 
					            APK = [os.path.join(basedir, 'repo', 'com.politedroid_3.apk')]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
 | 
					        signatures.extract(OptionsFixture)
 | 
				
			||||||
            signatures.extract(OptionsFixture)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # check if extracted signatures are where they are supposed to be
 | 
					        # check if extracted signatures are where they are supposed to be
 | 
				
			||||||
            # also verify weather if extracted file contain what they should
 | 
					        # also verify weather if extracted file contain what they should
 | 
				
			||||||
            filesAndHashes = (
 | 
					        filesAndHashes = (
 | 
				
			||||||
                (
 | 
					            (
 | 
				
			||||||
                    os.path.join(
 | 
					                os.path.join(
 | 
				
			||||||
                        'metadata', 'com.politedroid', 'signatures', '3', 'MANIFEST.MF'
 | 
					                    'metadata', 'com.politedroid', 'signatures', '3', 'MANIFEST.MF'
 | 
				
			||||||
                    ),
 | 
					 | 
				
			||||||
                    '7dcd83f0c41a75457fd2311bf3c4578f80d684362d74ba8dc52838d353f31cf2',
 | 
					 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                (
 | 
					                '7dcd83f0c41a75457fd2311bf3c4578f80d684362d74ba8dc52838d353f31cf2',
 | 
				
			||||||
                    os.path.join(
 | 
					            ),
 | 
				
			||||||
                        'metadata', 'com.politedroid', 'signatures', '3', 'RELEASE.RSA'
 | 
					            (
 | 
				
			||||||
                    ),
 | 
					                os.path.join(
 | 
				
			||||||
                    '883ef3d5a6e0bf69d2a58d9e255a7930f08a49abc38e216ed054943c99c8fdb4',
 | 
					                    'metadata', 'com.politedroid', 'signatures', '3', 'RELEASE.RSA'
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                (
 | 
					                '883ef3d5a6e0bf69d2a58d9e255a7930f08a49abc38e216ed054943c99c8fdb4',
 | 
				
			||||||
                    os.path.join(
 | 
					            ),
 | 
				
			||||||
                        'metadata', 'com.politedroid', 'signatures', '3', 'RELEASE.SF'
 | 
					            (
 | 
				
			||||||
                    ),
 | 
					                os.path.join(
 | 
				
			||||||
                    '99fbb3211ef5d7c1253f3a7ad4836eadc9905103ce6a75916c40de2831958284',
 | 
					                    'metadata', 'com.politedroid', 'signatures', '3', 'RELEASE.SF'
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
 | 
					                '99fbb3211ef5d7c1253f3a7ad4836eadc9905103ce6a75916c40de2831958284',
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        for path, checksum in filesAndHashes:
 | 
				
			||||||
 | 
					            self.assertTrue(
 | 
				
			||||||
 | 
					                os.path.isfile(path),
 | 
				
			||||||
 | 
					                f'check whether {path!r} was extracted correctly.',
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            for path, checksum in filesAndHashes:
 | 
					            with open(path, 'rb') as f:
 | 
				
			||||||
                self.assertTrue(
 | 
					                self.assertEqual(hashlib.sha256(f.read()).hexdigest(), checksum)
 | 
				
			||||||
                    os.path.isfile(path),
 | 
					 | 
				
			||||||
                    f'check whether {path!r} was extracted correctly.',
 | 
					 | 
				
			||||||
                )
 | 
					 | 
				
			||||||
                with open(path, 'rb') as f:
 | 
					 | 
				
			||||||
                    self.assertEqual(hashlib.sha256(f.read()).hexdigest(), checksum)
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue