Skip to content

A clinic on using factory boy for creating objects, testing and using pytest parameterize to test multiple cases.

Notifications You must be signed in to change notification settings

ryaustin/factories_param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Factories & Parameterization

A clinic on using factory boy for creating objects, testing and using pytest parameterize to test multiple cases.

While this repo accompanies the PDM 21st Feb 2023 Code clinic it can easily stand alone and be completed without watching that session.

Review the code and pay special attention to the tests directory where we:

  • build some factories using factory boy
  • use fake data provided by Faker
  • & create some parameterized tests using pytest
  • code challenge in test_accounts_and_profiles.py file to test your parameterization skills.

Honarable Mentions:

  • Type checking: for cleaner code (basic)
  • pytest_factory boy extension: to register factories in pytest
  • pip-compile: simple dependency mgmt
  • ipython: pdb on steriods

To get going, create a virtual environment and pip install -r requirements.txt.

ipython # https://ipython.org/ ipdb # https://pypi.org/project/ipdb/ factory-boy # https://factoryboy.readthedocs.io/en/latest/ faker # https://faker.readthedocs.io/en/master/ pytest-factoryboy # https://pypi.org/project/pytest-factoryboy/

About

A clinic on using factory boy for creating objects, testing and using pytest parameterize to test multiple cases.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages