• Interned at a startup called Jovian.ml where I worked on setting up the unit test suite for the jovian-py python library- github.com/jovianml/jovian-py • Google Summer of Code 2020 intern at NumFOCUS - working on a project called testbook, which is a unit testing library for Jupyter Notebooks - github.com/nteract/testbook Find my irregularly updated blog at rohitsanjay.com Follow me on twitter at @imrohitsanj About me
that a single component operates in the right way. • A unit test helps you to isolate what is broken in your application and fix it faster. Unit Testing in two sentences
need to remember self.assert* names) • Auto-discovery of test modules and functions (searches for test_*.py or *_test.py files) • Modular fixtures for managing small or parametrized long-lived test resources • Tests parametrization • Can run unittest test suites out of the box • Rich plugin architecture, with over 315+ external plugins and thriving community
object needs to follow so it can be used with the with statement. • You need to add __enter__ and __exit__ methods to an object if you want it to function as a context manager. • Python will call these two methods at the appropriate times in the resource management cycle. Context Managers in Python Are you with me?
and sys.stderr. • testdir - Provide a temporary test directory to aid in running, and testing, pytest plugins. • tmp_path - Provide a pathlib.Path object to a temporary directory which is unique to each test function. • tmpdir - Provide a py.path.local object to a temporary directory which is unique to each test function; replaced by tmp_path. pytest fixtures
of all the pytest features like fixtures and parametrize. Read more about it in their docs - docs.pytest.org • Use contextmanagers to perform setup and teardown functions • Use pytest plugins like pytest-cov to calculate code coverage on your tests Conclusion