コード例 #1
0
    def test_nested(self):
        """Test that nesting of type checker context managers works as expected."""
        def foo(a: int):
            pass

        with TypeChecker(__name__), pytest.warns(TypeWarning) as record:
            foo('x')
            with TypeChecker(__name__):
                foo('x')

        assert len(record) == 3
コード例 #2
0
ファイル: test_typeguard.py プロジェクト: kstauffer/typeguard
    def test_nested(self):
        """Test that nesting of type checker context managers works as expected."""
        def foo(a: int):
            pass

        with warnings.catch_warnings(record=True):
            warnings.simplefilter('ignore', DeprecationWarning)
            parent = TypeChecker(__name__)
            child = TypeChecker(__name__)

        with parent, pytest.warns(TypeWarning) as record:
            foo('x')
            with child:
                foo('x')

        assert len(record) == 3
コード例 #3
0
 def checker(self):
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', DeprecationWarning)
         return TypeChecker(__name__)
コード例 #4
0
 def checker(self):
     return TypeChecker(__name__)
コード例 #5
0
ファイル: typecheck.py プロジェクト: yangyang202/DA_GP9
def init_typeguard() -> None:
    from typeguard import TypeChecker
    global tc
    tc = TypeChecker(check_mods)
    tc.start()
コード例 #6
0
from __future__ import annotations

import logging
import os

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from pytest import fixture
from sqlalchemy.exc import SQLAlchemyError
from typeguard import TypeChecker

from labster.app import create_app
from labster.domain.services.constants import get_initial_constants
from labster.extensions import db as _db

checker = TypeChecker("labster")

if "TYPECHECK" in os.environ:
    logging.captureWarnings(True)
    if not checker.active:
        checker.start()


class TestConfig:
    TESTING = True
    CSRF_ENABLED = False
    MAIL_SENDER = "*****@*****.**"
    MAIL_SUPPRESS_SEND = True
    SECRET_KEY = "changeme"
    SERVER_NAME = "localhost.localdomain"
    SQLALCHEMY_DATABASE_URI = "sqlite://"
コード例 #7
0
Supposed to replace the too-complex current UnitTest-based testing
framework.

DI and functions over complex inheritance hierarchies FTW!
"""
import logging
import os
import warnings

import pytest
from typeguard import TypeChecker

pytest_plugins = ["abilian.testing.fixtures"]

if os.environ.get("TYPECHECK"):
    checker = TypeChecker("abilian")
    logging.captureWarnings(True)
    if not checker.active:
        checker.start()

if os.environ.get("FAIL_ON_WARNINGS"):
    # Don't remove !
    # noinspection PyUnresolvedReferences
    import pandas

    warnings.simplefilter("error")

if os.environ.get("COLLECT_ANNOTATIONS"):

    def pytest_collection_finish(session):
        """Handle the pytest collection finish hook: configure pyannotate.