File: test_error.py

package info (click to toggle)
python-filelock 3.19.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 196 kB
  • sloc: python: 1,490; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 863 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations

import pickle  # noqa: S403

from filelock import Timeout


def test_timeout_str() -> None:
    timeout = Timeout("/path/to/lock")
    assert str(timeout) == "The file lock '/path/to/lock' could not be acquired."


def test_timeout_repr() -> None:
    timeout = Timeout("/path/to/lock")
    assert repr(timeout) == "Timeout('/path/to/lock')"


def test_timeout_lock_file() -> None:
    timeout = Timeout("/path/to/lock")
    assert timeout.lock_file == "/path/to/lock"


def test_timeout_pickle() -> None:
    timeout = Timeout("/path/to/lock")
    timeout_loaded = pickle.loads(pickle.dumps(timeout))  # noqa: S301

    assert timeout.__class__ == timeout_loaded.__class__
    assert str(timeout) == str(timeout_loaded)
    assert repr(timeout) == repr(timeout_loaded)
    assert timeout.lock_file == timeout_loaded.lock_file