Advertisement
denees_k

logs tests

Jul 6th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. """
  2.    to launch tests: pytest --capture=sys -v
  3. """
  4. import pytest
  5.  
  6. from app import logs
  7. from conf import CONNT, NAME
  8.  
  9.  
  10. # All test coroutines will be treated as marked with this decorator.
  11. pytestmark = pytest.mark.asyncio
  12.  
  13.  
  14. async def test_logs_no_exception():
  15.     """
  16.    Assert log raises no exception.
  17.    """
  18.     try:
  19.         await logs(CONT, NAME)
  20.     except Exception as ex:
  21.         assert False, f'logs raised an exception - {ex}'
  22.  
  23.  
  24. async def test_logs_stdout(capsys):
  25.     """
  26.        Assert logs outputs info to stdout with the correct name
  27.    """
  28.     await logs(CONT, NAME)
  29.     captured = capsys.readouterr()
  30.     assert captured.out.find(NAME) != -1
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement