Test & Code cover image

Test & Code

221: How to get pytest to import your code under test

Jun 3, 2024
Exploring how to make pytest import your code under test including options like installing code with pip install -e /path/to/local/package and using the pythonpath pytest setting. Discussing the challenges of importing code for pytest and the benefits of packaging for distribution. Learning how to set the Python path in PyTest configuration files for code import.
07:19

Podcast summary created with Snipd AI

Quick takeaways

  • Setting up Python path in pytest settings is crucial for successful code import in testing.
  • Install the code under test as a pip installable package to allow test code import.

Deep dives

Importing Code Under Test

In this podcast episode, the focus is on importing the code under test for testing purposes. The host explains the importance of setting up the testing environment correctly so that tests can access the code under test. Whether it's a single Python file, a module with functions, or a directory package, the challenge lies in allowing the test code to import the necessary components.

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode