コード例 #1
0
def test_exit_PidfileProcessRunningException(tmp_path):
    path = os.path.join(
                         str(tmp_path),
                         'autorsyncbackup.pid',
                       )

    pf = Pidfile(path)

    pf.__enter__()

    exc_type = PidfileProcessRunningException
    exc_value = 'Mock value'
    exc_tb = 'Mock traceback'

    ret = pf.__exit__(exc_type, exc_value, exc_tb)

    assert ret is False

    assert os.path.exists(path) is True
コード例 #2
0
def test_exit_OSError(tmp_path):
    path = os.path.join(
                         str(tmp_path),
                         'autorsyncbackup.pid',
                       )

    pf = Pidfile(path)

    pf.__enter__()

    exc_type = OSError
    exc_value = 'Mock value'
    exc_tb = 'Mock traceback'

    ret = pf.__exit__(exc_type, exc_value, exc_tb)

    assert ret is False

    assert os.path.exists(path) is False
コード例 #3
0
def test_exit(tmp_path):
    path = os.path.join(
                         str(tmp_path),
                         'autorsyncbackup.pid',
                       )

    pf = Pidfile(path)

    pf.__enter__()

    exc_type = None
    exc_value = None
    exc_tb = None

    ret = pf.__exit__(exc_type, exc_value, exc_tb)

    assert ret is True

    assert os.path.exists(path) is False