Update stubs

This commit is contained in:
Trinh Anh Ngoc
2023-03-13 21:03:01 +07:00
parent e3384a6306
commit 47bd63fbaf
8 changed files with 150 additions and 79 deletions

View File

@@ -12,7 +12,6 @@ from watchdog.observers import Observer
from ..modules.registry import Registry from ..modules.registry import Registry
from ..sql_db import Cursor from ..sql_db import Cursor
from ..tests import runner as runner
_WorkerT = TypeVar('_WorkerT', bound=Worker) _WorkerT = TypeVar('_WorkerT', bound=Worker)

View File

@@ -117,12 +117,18 @@ class ConnectionPool:
def borrow(self, connection_info: dict) -> PsycoConnection: ... def borrow(self, connection_info: dict) -> PsycoConnection: ...
def give_back(self, connection: PsycoConnection, keep_in_pool: bool = ...) -> None: ... def give_back(self, connection: PsycoConnection, keep_in_pool: bool = ...) -> None: ...
def close_all(self, dsn: dict | None = ...) -> None: ... def close_all(self, dsn: dict | None = ...) -> None: ...
def _dsn_equals(self, dsn1, dsn2) -> bool: ...
def _dsn_to_dict(self, dsn) -> dict: ...
class Connection: class Connection:
dbname: str __dbname: str
dsn: dict __dsn: dict
__pool: ConnectionPool __pool: ConnectionPool
def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict) -> None: ... def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict) -> None: ...
@property
def dsn(self) -> dict: ...
@property
def dbname(self) -> str: ...
def cursor(self, **kwargs) -> Cursor: ... def cursor(self, **kwargs) -> Cursor: ...
def serialized_cursor(self, **kwargs) -> Cursor: ... def serialized_cursor(self, **kwargs) -> Cursor: ...
def __bool__(self) -> NoReturn: ... def __bool__(self) -> NoReturn: ...

51
odoo-stubs/tests/case.pyi Normal file
View File

@@ -0,0 +1,51 @@
from collections.abc import Generator
from typing import Any
from unittest import TestCase as _TestCase
__unittest: bool
_subtest_msg_sentinel: object
class _Outcome:
result: Any
success: bool
test: Any
def __init__(self, test, result) -> None: ...
def testPartExecutor(self, test_case, isTest: bool = ...) -> Generator[None, None, None]: ...
def _complete_traceback(self, initial_tb): ...
class TestCase(_TestCase):
_class_cleanups: list
__unittest_skip__: bool
__unittest_skip_why__: str
_moduleSetUpFailed: bool
_testMethodName: str
_outcome: Any
_cleanups: list
_subtest: Any
_type_equality_funcs: dict
def __init__(self, methodName: str = ...) -> None: ...
def addCleanup(self, function, *args, **kwargs) -> None: ...
@classmethod
def addClassCleanup(cls, function, *args, **kwargs) -> None: ...
def shortDescription(self) -> None: ...
def subTest(self, msg=..., **params) -> Generator[None, None, None]: ...
def _addError(self, result, test, exc_info) -> None: ...
def _callSetUp(self) -> None: ...
def _callTestMethod(self, method) -> None: ...
def _callTearDown(self) -> None: ...
def _callCleanup(self, function, *args, **kwargs) -> None: ...
def run(self, result): ...
def doCleanups(self) -> None: ...
@classmethod
def doClassCleanups(cls) -> None: ...
class _SubTest(TestCase):
_message: Any
test_case: Any
params: Any
failureException: Any
def __init__(self, test_case, message, params) -> None: ...
def runTest(self) -> None: ...
def _subDescription(self) -> str: ...
def id(self) -> str: ...
def __str__(self) -> str: ...

View File

@@ -1,22 +1,18 @@
import collections import collections
import logging import logging
import sys import sys
import unittest
from concurrent.futures import Future from concurrent.futures import Future
from re import Pattern
from types import TracebackType
from itertools import count from itertools import count
from subprocess import Popen from subprocess import Popen
from threading import Thread from threading import Thread
from typing import Any, Callable, Generator, Generic, Iterator, Mapping, Match, TypeVar from typing import Any, Callable, Generator, Generic, Iterator, Mapping, Match, TypeVar
from unittest import TestCase, TestSuite
from xmlrpc import client as xmlrpclib from xmlrpc import client as xmlrpclib
import requests import requests
from lxml.etree import _Element from lxml.etree import _Element
from websocket import WebSocket from websocket import WebSocket
from . import case
from .runner import OdooTestResult from .runner import OdooTestResult
from ..api import Environment from ..api import Environment
from ..http import Session from ..http import Session
@@ -61,34 +57,20 @@ class RecordCapturer:
@property @property
def records(self) -> BaseModel: ... def records(self) -> BaseModel: ...
BackportSuite: type[TestSuite]
class OdooSuite(BackportSuite):
def _handleClassSetUp(self, test, result) -> None: ...
def _tearDownPreviousClass(self, test, result) -> None: ...
def has_http_case(self) -> bool: ...
class MetaCase(type): class MetaCase(type):
def __init__(cls, name, bases, attrs) -> None: ... def __init__(cls, name, bases, attrs) -> None: ...
def _normalize_arch_for_assert(arch_string: str, parser_method: str = ...) -> str: ... def _normalize_arch_for_assert(arch_string: str, parser_method: str = ...) -> str: ...
class BaseCase(unittest.TestCase, metaclass=MetaCase): class BaseCase(case.TestCase, metaclass=MetaCase):
_python_version: tuple
_class_cleanups: list
tearDown_exceptions: list
registry: Registry registry: Registry
env: Environment env: Environment
cr: Cursor cr: Cursor
@classmethod
def addClassCleanup(cls, function, *args, **kwargs) -> None: ...
@classmethod
def doClassCleanups(cls) -> None: ...
longMessage: bool longMessage: bool
warm: bool warm: bool
_python_version: tuple
def __init__(self, methodName: str = ...) -> None: ... def __init__(self, methodName: str = ...) -> None: ...
def run(self, result: OdooTestResult) -> None: ... def run(self, result: OdooTestResult) -> None: ...
def shortDescription(self) -> None: ...
def cursor(self) -> Cursor: ... def cursor(self) -> Cursor: ...
@property @property
def uid(self) -> int: ... def uid(self) -> int: ...
@@ -118,14 +100,6 @@ class BaseCase(unittest.TestCase, metaclass=MetaCase):
def assertHTMLEqual(self, original: str, expected: str) -> None: ... def assertHTMLEqual(self, original: str, expected: str) -> None: ...
profile_session: str profile_session: str
def profile(self, description: str = ..., **kwargs) -> Profiler: ... def profile(self, description: str = ..., **kwargs) -> Profiler: ...
def _callSetUp(self) -> None: ...
class _ErrorCatcher(list):
__slots__ = ['test']
test: TestCase
def __init__(self, test: TestCase) -> None: ...
def append(self, error) -> None: ...
def _complete_traceback(self, initial_tb: TracebackType) -> TracebackType: ...
savepoint_seq: count[int] savepoint_seq: count[int]
@@ -343,10 +317,3 @@ def record_to_values(fields: dict, record: BaseModel) -> dict: ...
def _cleanup_from_default(type_: str, value): ... def _cleanup_from_default(type_: str, value): ...
def _get_node(view, f, *arg): ... def _get_node(view, f, *arg): ...
def tagged(*tags: str) -> Callable[[_CallableT], _CallableT]: ... def tagged(*tags: str) -> Callable[[_CallableT], _CallableT]: ...
class TagsSelector:
filter_spec_re: Pattern
exclude: set
include: set
def __init__(self, spec: str) -> None: ...
def check(self, test) -> bool: ...

View File

@@ -0,0 +1,53 @@
from collections.abc import Generator
from logging import Logger
from re import Pattern
from typing import Any, NamedTuple
__unittest: bool
STDOUT_LINE: str
STDERR_LINE: str
stats_logger: Logger
class Stat(NamedTuple):
time: float
queries: int
def __add__(self, other: Stat) -> Stat: ...
_TEST_ID: Pattern
class OdooTestResult:
_previousTestClass: Any
_moduleSetUpFailed: bool
failures_count: int
errors_count: int
testsRun: int
skipped: int
tb_locals: bool
time_start: float | None
queries_start: int | None
_soft_fail: bool
had_failure: bool
stats: dict[str, Stat]
def __init__(self, stream: Any | None = ..., descriptions: Any | None = ..., verbosity: Any | None = ...) -> None: ...
def printErrors(self) -> None: ...
def startTest(self, test) -> None: ...
def stopTest(self, test) -> None: ...
def addError(self, test, err) -> None: ...
def addFailure(self, test, err) -> None: ...
def addSubTest(self, test, subtest, err) -> None: ...
def addSuccess(self, test) -> None: ...
def addSkip(self, test, reason) -> None: ...
def wasSuccessful(self) -> bool: ...
def _exc_info_to_string(self, err, test) -> str: ...
def _is_relevant_tb_level(self, tb) -> bool: ...
def _count_relevant_tb_levels(self, tb) -> int: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def soft_fail(self) -> Generator[None, None, None]: ...
def update(self, other) -> None: ...
def log(self, level, msg, *args, test: Any | None = ..., exc_info: Any | None = ..., extra: Any | None = ..., stack_info: bool = ..., caller_infos: Any | None = ...) -> None: ...
def log_stats(self) -> None: ...
def getDescription(self, test) -> str: ...
def collectStats(self, test_id) -> Generator[None, None, None]: ...
def logError(self, flavour, test, error) -> None: ...
def getErrorCallerInfo(self, error, test) -> tuple | None: ...

View File

@@ -1,40 +0,0 @@
import unittest
from collections import defaultdict
from logging import Logger
from re import Pattern
from typing import Any, Generator, NamedTuple
stats_logger: Logger
class Stat(NamedTuple):
time: float
queries: int
def __add__(self, other: Stat) -> Stat: ...
_TEST_ID: Pattern
class OdooTestResult(unittest.result.TestResult):
time_start: float | None
queries_start: int | None
_soft_fail: bool
had_failure: bool
stats: defaultdict[Any, Stat]
def __init__(self) -> None: ...
def __str__(self) -> str: ...
def soft_fail(self) -> Generator[None, None, None]: ...
shouldStop: Any
def update(self, other) -> None: ...
def log(self, level, msg, *args, test: Any | None = ..., exc_info: Any | None = ..., extra: Any | None = ...,
stack_info: bool = ..., caller_infos: Any | None = ...) -> None: ...
def log_stats(self) -> None: ...
def getDescription(self, test): ...
def startTest(self, test) -> None: ...
def stopTest(self, test) -> None: ...
def collectStats(self, test_id) -> Generator[None, None, None]: ...
def addError(self, test, err) -> None: ...
def addFailure(self, test, err) -> None: ...
def addSubTest(self, test, subtest, err) -> None: ...
def addSkip(self, test, reason) -> None: ...
def addUnexpectedSuccess(self, test) -> None: ...
def logError(self, flavour, test, error) -> None: ...
def getErrorCallerInfo(self, error, test): ...

View File

@@ -0,0 +1,27 @@
from typing import Any
from unittest import BaseTestSuite
__unittest: bool
class TestSuite(BaseTestSuite):
def run(self, result, debug: bool = ...): ...
def _handleClassSetUp(self, test, result) -> None: ...
def _createClassOrModuleLevelException(self, result, exception, method_name, parent, info: Any | None = ...) -> None: ...
def _tearDownPreviousClass(self, test, result) -> None: ...
class _ErrorHolder:
failureException: Any
description: str
def __init__(self, description: str) -> None: ...
def id(self) -> str: ...
def shortDescription(self) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def run(self, result) -> None: ...
def __call__(self, result) -> None: ...
def countTestCases(self) -> int: ...
class OdooSuite(TestSuite):
def _handleClassSetUp(self, test, result) -> None: ...
def _tearDownPreviousClass(self, test, result) -> None: ...
def has_http_case(self) -> bool: ...

View File

@@ -0,0 +1,8 @@
from re import Pattern
class TagsSelector:
filter_spec_re: Pattern
exclude: set
include: set
def __init__(self, spec: str) -> None: ...
def check(self, test) -> bool: ...