(self, open_, fdopen, osopen, getpid, fsync)
| 861 | @patch('os.fdopen') |
| 862 | @patch('builtins.open') |
| 863 | def test_write_pid(self, open_, fdopen, osopen, getpid, fsync): |
| 864 | getpid.return_value = 1816 |
| 865 | osopen.return_value = 13 |
| 866 | w = fdopen.return_value = WhateverIO() |
| 867 | w.close = Mock() |
| 868 | r = open_.return_value = WhateverIO() |
| 869 | r.write('1816\n') |
| 870 | r.seek(0) |
| 871 | |
| 872 | p = Pidfile('/var/pid') |
| 873 | p.write_pid() |
| 874 | w.seek(0) |
| 875 | assert w.readline() == '1816\n' |
| 876 | w.close.assert_called() |
| 877 | getpid.assert_called_with() |
| 878 | osopen.assert_called_with( |
| 879 | p.path, platforms.PIDFILE_FLAGS, platforms.PIDFILE_MODE, |
| 880 | ) |
| 881 | fdopen.assert_called_with(13, 'w') |
| 882 | fsync.assert_called_with(13) |
| 883 | open_.assert_called_with(p.path) |
| 884 | |
| 885 | @patch('os.fsync') |
| 886 | @patch('os.getpid') |
nothing calls this directly
no test coverage detected