circleci
11 of 35 new or added lines in 2 files covered. (31.43%)
13656 existing lines in 309 files now uncovered.42766 of 53759 relevant lines covered (79.55%)
1.63 hits per line
| 1 |
# encoding: utf-8
|
|
| 2 |
|
|
|
UNCOV
3
|
from __future__ import annotations |
1✔ |
| 4 |
|
|
|
UNCOV
5
|
from typing import Any |
1✔ |
|
UNCOV
6
|
from ckan.types import Validator |
1✔ |
| 7 |
|
|
| 8 |
|
|
|
UNCOV
9
|
from ckan.plugins.toolkit import Invalid |
1✔ |
|
UNCOV
10
|
from ckan import plugins |
1✔ |
| 11 |
|
|
| 12 |
|
|
|
UNCOV
13
|
class ExampleIValidatorsPlugin(plugins.SingletonPlugin): |
1✔ |
|
UNCOV
14
|
plugins.implements(plugins.IValidators) |
1✔ |
| 15 |
|
|
|
UNCOV
16
|
def get_validators(self) -> dict[str, Validator]: |
1✔ |
|
UNCOV
17
|
return {
|
1✔ |
| 18 |
u'equals_fortytwo': equals_fortytwo,
|
|
| 19 |
u'negate': negate,
|
|
| 20 |
u'unicode_only': unicode_please,
|
|
| 21 |
} |
|
| 22 |
|
|
| 23 |
|
|
|
UNCOV
24
|
def equals_fortytwo(value: Any): |
1✔ |
|
UNCOV
25
|
if value != 42: |
1✔ |
|
UNCOV
26
|
raise Invalid(u'not 42') |
1✔ |
|
UNCOV
27
|
return value
|
1✔ |
| 28 |
|
|
| 29 |
|
|
|
UNCOV
30
|
def negate(value: Any): |
1✔ |
|
UNCOV
31
|
return -value
|
× |
| 32 |
|
|
| 33 |
|
|
|
UNCOV
34
|
def unicode_please(value: Any): |
1✔ |
|
UNCOV
35
|
if isinstance(value, bytes): |
× |
| 36 |
try:
|
× |
| 37 |
return str(value) |
× |
| 38 |
except UnicodeDecodeError: |
× |
| 39 |
return value.decode(u'cp1252') |
× |
|
UNCOV
40
|
return str(value) |
× |