| |
@@ -19,6 +19,7 @@
|
| |
import sys
|
| |
import tempfile
|
| |
from types import ModuleType
|
| |
+ import unittest
|
| |
import unittest.mock
|
| |
import warnings
|
| |
|
| |
@@ -375,6 +376,7 @@
|
| |
self.mock_module_daemon.attach_mock(
|
| |
unittest.mock.Mock(), 'DaemonContext')
|
| |
|
| |
+ make_fake_streams(self)
|
| |
self.test_files_preserve_fds = object()
|
| |
self.test_signal_handler_map = object()
|
| |
daemoncontext_method_return_values = {
|
| |
@@ -553,6 +555,25 @@
|
| |
self.mock_module_daemon.redirect_stream.assert_has_calls(
|
| |
expected_calls, any_order=True)
|
| |
|
| |
+ @unittest.skipIf(
|
| |
+ sys.platform != 'windows',
|
| |
+ "File handles implemented only on MS Windows")
|
| |
+ @unittest.mock.patch.object(os, "set_inheritable")
|
| |
+ def test_duplicate_is_inheritable(
|
| |
+ self, mock_func_os_set_inheritable):
|
| |
+ """ The system streams should be inheritable.
|
| |
+
|
| |
+ dup2 sets the new file descriptors to be inhertiable. But if the
|
| |
+ old and new file descriptors are equal, the inheritable attribute
|
| |
+ is not changed.
|
| |
+ If the system streams aren't inheritable they would not be copied
|
| |
+ to any children of the daemon.
|
| |
+ """
|
| |
+ test_stream = self.fake_streams['stdout']
|
| |
+ stream_fileno = test_stream.fileno()
|
| |
+ daemon.daemon.redirect_stream(test_stream, test_stream)
|
| |
+ mock_func_os_set_inheritable.assert_called_with(stream_fileno, True)
|
| |
+
|
| |
def test_enters_pidfile_context(self):
|
| |
""" Should enter the PID file context manager. """
|
| |
instance = self.test_instance
|
| |
Closes: Pagure issue #57.