summaryrefslogtreecommitdiffstats
path: root/tests/test_install_progress_exec.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
commit76926159194e180003aa78de97e5f287bf4325a5 (patch)
tree2cea7245cdc3f66355900c820c145eba90598766 /tests/test_install_progress_exec.py
parentInitial commit. (diff)
downloadpython-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz
python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_install_progress_exec.py')
-rw-r--r--tests/test_install_progress_exec.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_install_progress_exec.py b/tests/test_install_progress_exec.py
new file mode 100644
index 0000000..064eb81
--- /dev/null
+++ b/tests/test_install_progress_exec.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python3
+#
+# Copyright (C) 2019 Colomban Wendling <cwendling@hypra.fr>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+"""Unit tests for verifying InstallProgress works when spawning dpkg directly
+(i.e. when installing standalone .debs)."""
+import os
+import sys
+import unittest
+
+from test_all import get_library_dir
+
+libdir = get_library_dir()
+if libdir:
+ sys.path.insert(0, libdir)
+import testcommon
+
+from apt.progress.base import InstallProgress
+
+
+class RunHelper:
+ def __init__(self):
+ self.script = "helper_install_progress_run.py"
+
+ def do_install(self, fd):
+ return os.spawnl(os.P_WAIT, self.script, self.script, str(fd))
+
+
+class TestInstallProgressExec(testcommon.TestCase):
+ """test that InstallProgress.run() passes a valid file descriptor to
+ a child process"""
+
+ def test_run(self):
+ with InstallProgress() as prog:
+ self.assertEqual(prog.run(RunHelper()), 0)
+
+
+if __name__ == "__main__":
+ os.chdir(os.path.dirname(__file__))
+ unittest.main()