Passed
Push — main ( ed7d21...87238c )
by Douglas
01:43
created

pocketutils.core.mocks   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 19
dl 0
loc 29
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A MockWritable.flush() 0 2 1
A MockWritable.__init__() 0 2 1
A MockCallable.__call__() 0 2 1
A MockWritable.write() 0 3 1
A MockCallable.__init__() 0 2 1
A MockWritable.close() 0 2 1
1
from typing import Any, Self
2
3
4
class MockWritable:
5
    def __init__(self: Self) -> None:
6
        self.data = None
7
8
    def write(self, data: Any) -> int:
9
        self.data = "write:" + str(data)
10
        return len(data)
11
12
    def flush(self: Self) -> None:
13
        self.data += "flush"
14
15
    def close(self: Self) -> None:
16
        self.data += "close"
17
18
19
class MockCallable:
20
    def __init__(self: Self) -> None:
21
        self.data = None
22
23
    def __call__(self, data: Self) -> None:
24
        self.data = "call:" + data
25
26
27
class WritableCallable(MockWritable, MockCallable):
28
    pass
29