feat: basefiles

This commit is contained in:
cătălin 2023-10-02 22:46:29 +02:00
commit bdf9e90efa
Signed by: catalin
GPG key ID: 686088EF78EE4083
16 changed files with 1299 additions and 0 deletions

0
tests/__init__.py Normal file
View file

16
tests/conftest.py Normal file
View file

@ -0,0 +1,16 @@
import logging
import pytest
@pytest.fixture()
def anyio_backend():
return 'trio'
@pytest.fixture()
def logger():
logging.basicConfig()
logger = logging.getLogger("test_logger")
logger.setLevel(logging.INFO)
return logger

26
tests/test_muzzle.py Normal file
View file

@ -0,0 +1,26 @@
import pytest
import shush
def test_muzzle(caplog, logger):
@shush.muzzle("foo")
def muzzled_func():
logger.info("this contains `foo` so it should be muzzled out")
logger.info("this doesn't contain it so it should be showing")
muzzled_func()
assert caplog.text == ("INFO test_logger:test_muzzle.py:10 "
"this doesn't contain it so it should be showing\n")
@pytest.mark.anyio()
async def test_muzzle_async(caplog, logger):
@shush.muzzle("foo")
async def muzzled_func():
logger.info("this contains `foo` so it should be muzzled out")
logger.info("this doesn't contain it so it should be showing")
await muzzled_func()
assert caplog.text == ("INFO test_logger:test_muzzle.py:22 "
"this doesn't contain it so it should be showing\n")

36
tests/test_supress.py Normal file
View file

@ -0,0 +1,36 @@
import pytest
import shush
def test_supress(caplog, logger):
@shush.suppress
def suppressed_func():
logger.info("This log should not appear")
def normal_func():
logger.info("This log should appear")
suppressed_func()
assert caplog.records == []
normal_func()
assert caplog.text == ('INFO test_logger:test_supress.py:12 '
'This log should appear\n')
@pytest.mark.anyio()
async def test_supress_async(caplog, logger):
@shush.suppress
async def suppressed_func_async():
logger.info("This log should not appear")
async def normal_func_async():
logger.info("This log should appear")
await suppressed_func_async()
assert caplog.records == []
await normal_func_async()
assert caplog.text == ('INFO test_logger:test_supress.py:29 '
'This log should appear\n')