(self, _close_fds, dup2, open, close, closer, umask, chdir,
_exit, setsid, fork, run_after_forkers)
| 615 | @patch('os.dup2') |
| 616 | @patch('celery.platforms.close_open_fds') |
| 617 | def test_open(self, _close_fds, dup2, open, close, closer, umask, chdir, |
| 618 | _exit, setsid, fork, run_after_forkers): |
| 619 | x = DaemonContext(workdir='/opt/workdir', umask=0o22) |
| 620 | x.stdfds = [0, 1, 2] |
| 621 | |
| 622 | fork.return_value = 0 |
| 623 | with x: |
| 624 | assert x._is_open |
| 625 | with x: |
| 626 | pass |
| 627 | assert fork.call_count == 2 |
| 628 | setsid.assert_called_with() |
| 629 | _exit.assert_not_called() |
| 630 | |
| 631 | chdir.assert_called_with(x.workdir) |
| 632 | umask.assert_called_with(0o22) |
| 633 | dup2.assert_called() |
| 634 | |
| 635 | fork.reset_mock() |
| 636 | fork.return_value = 1 |
| 637 | x = DaemonContext(workdir='/opt/workdir') |
| 638 | x.stdfds = [0, 1, 2] |
| 639 | with x: |
| 640 | pass |
| 641 | assert fork.call_count == 1 |
| 642 | _exit.assert_called_with(0) |
| 643 | |
| 644 | x = DaemonContext(workdir='/opt/workdir', fake=True) |
| 645 | x.stdfds = [0, 1, 2] |
| 646 | x._detach = Mock() |
| 647 | with x: |
| 648 | pass |
| 649 | x._detach.assert_not_called() |
| 650 | |
| 651 | x.after_chdir = Mock() |
| 652 | with x: |
| 653 | pass |
| 654 | x.after_chdir.assert_called_with() |
| 655 | |
| 656 | x = DaemonContext(workdir='/opt/workdir', umask='0755') |
| 657 | assert x.umask == 493 |
| 658 | x = DaemonContext(workdir='/opt/workdir', umask='493') |
| 659 | assert x.umask == 493 |
| 660 | |
| 661 | x.redirect_to_null(None) |
| 662 | |
| 663 | with patch('celery.platforms.mputil') as mputil: |
| 664 | x = DaemonContext(after_forkers=True) |
| 665 | x.open() |
| 666 | mputil._run_after_forkers.assert_called_with() |
| 667 | x = DaemonContext(after_forkers=False) |
| 668 | x.open() |
| 669 | |
| 670 | |
| 671 | @t.skip.if_win32 |
nothing calls this directly
no test coverage detected