(self, open_, fdopen, osopen, getpid, fsync)
| 711 | @patch('os.fdopen') |
| 712 | @patch('builtins.open') |
| 713 | def test_write_pid(self, open_, fdopen, osopen, getpid, fsync): |
| 714 | getpid.return_value = 1816 |
| 715 | osopen.return_value = 13 |
| 716 | w = fdopen.return_value = WhateverIO() |
| 717 | w.close = Mock() |
| 718 | r = open_.return_value = WhateverIO() |
| 719 | r.write('1816\n') |
| 720 | r.seek(0) |
| 721 | |
| 722 | p = Pidfile('/var/pid') |
| 723 | p.write_pid() |
| 724 | w.seek(0) |
| 725 | assert w.readline() == '1816\n' |
| 726 | w.close.assert_called() |
| 727 | getpid.assert_called_with() |
| 728 | osopen.assert_called_with( |
| 729 | p.path, platforms.PIDFILE_FLAGS, platforms.PIDFILE_MODE, |
| 730 | ) |
| 731 | fdopen.assert_called_with(13, 'w') |
| 732 | fsync.assert_called_with(13) |
| 733 | open_.assert_called_with(p.path) |
| 734 | |
| 735 | @patch('os.fsync') |
| 736 | @patch('os.getpid') |
nothing calls this directly
no test coverage detected