tests.pocketutils.core.test_core   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 22
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestCore.test_wrap() 0 14 1
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
from datetime import datetime
5
from typing import Self
6
7
import pytest
8
from pocketutils.core import LazyWrap
9
10
11
class TestCore:
12
    def test_wrap(self: Self):
13
        DT = LazyWrap.new_type("datetime", datetime.now)
14
        dt = DT()
15
        assert str(dt) == "datetime[⌀]"
16
        assert not dt.is_defined
17
        assert dt.raw_value is None
18
        v = dt.get()
19
        assert isinstance(v, datetime)
20
        assert dt.raw_value == v
21
        assert dt.is_defined
22
        a, b = DT(), DT()
23
        assert a == b
24
        a.get()
25
        assert a != b
26
27
28
if __name__ == "__main__":
29
    pytest.main()
30