MCPcopy
hub / github.com/celery/celery / test_write_pid

Method test_write_pid

t/unit/utils/test_platforms.py:713–733  ·  view source on GitHub ↗
(self, open_, fdopen, osopen, getpid, fsync)

Source from the content-addressed store, hash-verified

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')

Callers

nothing calls this directly

Calls 5

write_pidMethod · 0.95
WhateverIOClass · 0.90
PidfileClass · 0.90
readlineMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected