def test_mod_hostname(self):
        self.assertFalse(network.mod_hostname(None))

        with patch.object(salt.utils, 'which', return_value='hostname'):
            with patch.dict(network.__salt__,
                            {'cmd.run': MagicMock(return_value=None)}):
                file_d = '\n'.join(['#', 'A B C D,E,F G H'])
                with patch('salt.utils.fopen', mock_open(read_data=file_d),
                           create=True) as mfi:
                    mfi.return_value.__iter__.return_value = file_d.splitlines()
                    with patch.dict(network.__grains__, {'os_family': 'A'}):
                        self.assertTrue(network.mod_hostname('hostname'))
Test for Modify hostname
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/network_test.py/NetworkTestCase.test_mod_hostname