pocketutils.core.mocks.MockWritable.close()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
# SPDX-FileCopyrightText: Copyright 2020-2023, Contributors to pocketutils
2
# SPDX-PackageHomePage: https://github.com/dmyersturnbull/pocketutils
3
# SPDX-License-Identifier: Apache-2.0
4
"""
5
6
"""
7
8
from typing import Any, Self
9
10
11
class MockWritable:
12
    def __init__(self: Self) -> None:
13
        self.data = None
14
15
    def write(self, data: Any) -> int:
16
        self.data = "write:" + str(data)
17
        return len(data)
18
19
    def flush(self: Self) -> None:
20
        self.data += "flush"
21
22
    def close(self: Self) -> None:
23
        self.data += "close"
24
25
26
class MockCallable:
27
    def __init__(self: Self) -> None:
28
        self.data = None
29
30
    def __call__(self, data: Self) -> None:
31
        self.data = "call:" + data
32
33
34
class WritableCallable(MockWritable, MockCallable):
35
    pass
36