Пример #1
0
def test_debian_tz_path_doesnt_exist_forced(timezone, tz_path):
    mo = mock.mock_open()
    with mock.patch("tzupdate.open", mo, create=True):
        tzupdate.write_debian_timezone(timezone, tz_path, must_exist=False)
        mo.assert_called_once_with(tz_path, "w")
        mo().seek.assert_called_once_with(0)
        mo().write.assert_called_once_with(timezone + "\n")
Пример #2
0
def test_debian_tz_path_other_error_raises(timezone, tz_path):
    mo = mock.mock_open()
    code = errno.EPERM
    mo.side_effect = OSError(code, "")
    with mock.patch("tzupdate.open", mo, create=True):
        with pytest.raises(OSError) as thrown_exc:
            tzupdate.write_debian_timezone(timezone, tz_path, must_exist=True)
        assert thrown_exc.value.errno == code
Пример #3
0
def test_debian_tz_path(timezone, tz_path):
    mo = mock.mock_open()
    with mock.patch('tzupdate.open', mo, create=True):
        tzupdate.write_debian_timezone(timezone, tz_path)
        mo.assert_called_once_with(tz_path, 'w')
        mo().write.assert_called_once_with(timezone + '\n')
Пример #4
0
def test_debian_tz_path_doesnt_exist_not_forced(timezone, tz_path):
    mo = mock.mock_open()
    mo.side_effect = OSError(errno.ENOENT, "")
    with mock.patch("tzupdate.open", mo, create=True):
        tzupdate.write_debian_timezone(timezone, tz_path, must_exist=True)
        mo.assert_called_once_with(tz_path, "r+")
Пример #5
0
def test_debian_tz_path(timezone, tz_path):
    mo = mock.mock_open()
    with mock.patch("tzupdate.open", mo, create=True):
        tzupdate.write_debian_timezone(timezone, tz_path)
        mo.assert_called_once_with(tz_path, "w")
        mo().write.assert_called_once_with(timezone + "\n")