예제 #1
0
 def test_gentoo_is_systemd(self):
     f = mock.mock_open(read_data='systemd')
     with mock.patch('__main__.file', f, create=True) as m:
         self.assertEqual(gentoo.is_systemd(), True)
         m.assert_called_once_with('/proc/1/comm')
     f = mock.mock_open(read_data='init')
     with mock.patch('__main__.file', f, create=True) as m:
         self.assertEqual(gentoo.is_systemd(), False)
         m.assert_called_once_with('/proc/1/comm')
     f = mock.mock_open(read_data='upstart')
     with mock.patch('__main__.file', f, create=True) as m:
         self.assertEqual(gentoo.is_systemd(), False)
         m.assert_called_once_with('/proc/1/comm')
예제 #2
0
    def test_gentoo_is_systemd(self):
        import sys
        if sys.version_info >= (3, 0):
            mocked_fn = 'builtins.open'
        else:
            mocked_fn = '__builtin__.open'

        f = mock.mock_open(read_data='systemd')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), True)
            m.assert_called_once_with('/proc/1/comm')
        f = mock.mock_open(read_data='init')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), False)
            m.assert_called_once_with('/proc/1/comm')
        f = mock.mock_open(read_data='upstart')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), False)
            m.assert_called_once_with('/proc/1/comm')
예제 #3
0
파일: test_all.py 프로젝트: ApusApp/ceph
    def test_gentoo_is_systemd(self):
        import sys
        if sys.version_info >= (3, 0):
            mocked_fn = 'builtins.open'
        else:
            mocked_fn = '__builtin__.open'

        f = mock.mock_open(read_data='systemd')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), True)
            m.assert_called_once_with('/proc/1/comm')
        f = mock.mock_open(read_data='init')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), False)
            m.assert_called_once_with('/proc/1/comm')
        f = mock.mock_open(read_data='upstart')
        with mock.patch(mocked_fn, f, create=True) as m:
            self.assertEqual(gentoo.is_systemd(), False)
            m.assert_called_once_with('/proc/1/comm')