MCPcopy Create free account
hub / github.com/celery/celery / test_write_pid

Method test_write_pid

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

Source from the content-addressed store, hash-verified

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

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