diff --git a/tests/shared_test_code.py b/tests/shared_test_code.py index ec095508..59f515a7 100644 --- a/tests/shared_test_code.py +++ b/tests/shared_test_code.py @@ -79,7 +79,7 @@ def mkdir_testfiles(localmodule, test): testroot.mkdir(exist_ok=True) testdir = testroot / unittest.TestCase.id(test) testdir.mkdir(exist_ok=True) - return tempfile.mkdtemp(dir=testdir) + return Path(tempfile.mkdtemp(dir=testdir)) def mock_urlopen(status=200, body=None): diff --git a/tests/test_integration.py b/tests/test_integration.py index f0a5b04f..5fc263d4 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -17,6 +17,8 @@ try: except ModuleNotFoundError: from androguard.core.apk import get_apkid +from .shared_test_code import mkdir_testfiles + # TODO: port generic tests that use index.xml to index-v2 (test that # explicitly test index-v0 should still use index.xml) @@ -44,9 +46,6 @@ class IntegrationTest(unittest.TestCase): except KeyError: cls.fdroid_cmd = [WORKSPACE / "fdroid"] - cls.tmp = WORKSPACE / ".testfiles" - cls.tmp_repo = cls.tmp / "repo" - os.environ.update( { "GIT_AUTHOR_NAME": "Test", @@ -59,12 +58,14 @@ class IntegrationTest(unittest.TestCase): def setUp(self): self.prev_cwd = Path() - self.tmp_repo.mkdir(parents=True) - os.chdir(self.tmp_repo) + self.testdir = mkdir_testfiles(WORKSPACE, self) + self.tmp_repo_root = self.testdir / "fdroid" + self.tmp_repo_root.mkdir(parents=True) + os.chdir(self.tmp_repo_root) def tearDown(self): os.chdir(self.prev_cwd) - shutil.rmtree(self.tmp) + shutil.rmtree(self.testdir) def assert_run(self, *args, **kwargs): proc = subprocess.run(*args, **kwargs) @@ -795,7 +796,7 @@ class IntegrationTest(unittest.TestCase): self.update_yaml( "config.yml", {"categories": ["Internet"], "java_paths": {}}, replace=True ) - local_copy_dir = self.tmp / "fdroid" + local_copy_dir = self.testdir / "local_copy_dir/fdroid" (local_copy_dir / "repo").mkdir(parents=True) self.update_yaml( "config.yml", {"local_copy_dir": str(local_copy_dir.resolve())} @@ -819,8 +820,8 @@ class IntegrationTest(unittest.TestCase): self.assert_run(self.fdroid_cmd + ["init"]) self.assert_run(self.fdroid_cmd + ["update", "--create-metadata", "--verbose"]) self.assert_run(self.fdroid_cmd + ["readmeta"]) - local_copy_dir = (self.tmp / "fdroid").resolve() - local_copy_dir.mkdir() + local_copy_dir = (self.testdir / "local_copy_dir/fdroid").resolve() + local_copy_dir.mkdir(parents=True) self.assert_run( self.fdroid_cmd + ["deploy", "--local-copy-dir", local_copy_dir] ) @@ -859,12 +860,13 @@ class IntegrationTest(unittest.TestCase): self.assert_run(self.fdroid_cmd + ["readmeta"]) self.assertIn("