Passed
Push — main ( 60119b...e5c7f7 )
by Douglas
02:02
created

tests.pocketutils.misc.test_templates   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestTemplates.test() 0 15 1
1
from datetime import datetime
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
4
5
from pocketutils.misc.magic_template import *
0 ignored issues
show
Unused Code introduced by
PathLike was imported with wildcard, but is not used.
Loading history...
Coding Style introduced by
The usage of wildcard imports like pocketutils.misc.magic_template should generally be avoided.
Loading history...
Unused Code introduced by
LazyWrap was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Union was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
logging was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
logger was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Path was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Any was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Callable was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Optional was imported with wildcard, but is not used.
Loading history...
6
7
8
class TestTemplates:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
9
    def test(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
10
        assert MagicTemplate.from_text("abc ${{x}}").add("x", 1).parse() == "abc 1"
11
        assert (
12
            MagicTemplate.from_text("abc ${{minor}} ${{major}} ${{patch}}")
13
            .add_version("1.3.9")
14
            .parse()
15
            == "abc 3 1 9"
16
        )
17
        at = datetime(2001, 2, 2)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "at" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
18
        assert (
19
            MagicTemplate.from_text("abc ${{datetuple}}").add_datetime(at).parse()
20
            == "abc (2001, 2, 2)"
21
        )
22
        assert (
23
            MagicTemplate.from_text("abc ${{datetuple}}").add_datetime().parse().startswith("abc")
24
        )
25
26
27
if __name__ == "__main__":
28
    pytest.main()
29