Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 485 Bytes

File metadata and controls

39 lines (32 loc) · 485 Bytes

Testing & Debugging

assert

assert 2 + 2 == 4

unittest

import unittest
class TestAdd(unittest.TestCase):
    def test_add(self):
        self.assertEqual(1+1, 2)

pytest

Run: pytest test_file.py

def test_add(): assert 1+1 == 2


## Mocking
```python
from unittest.mock import Mock
m = Mock(return_value=42)
print(m())

Logging

import logging
logging.info('Info!')

pdb

import pdb; pdb.set_trace()