    Skip to content

      Navigation Menu

            Sign in Appearance settings
                * Platform
                        + AI CODE CREATION
                            o GitHub Copilot Write better code with AI
                            o GitHub Copilot app Direct agents from issue to merge
                            o MCP Registry Integrate external tools
                        + DEVELOPER WORKFLOWS
                            o Actions Automate any workflow
                            o Codespaces Instant dev environments
                            o Issues Plan and track work
                            o Code Review Manage code changes
                            o Code Quality Enforce quality at merge
                        + APPLICATION SECURITY
                            o GitHub Advanced Security Find and fix vulnerabilities
                            o Code security Secure your code as you build
                            o Secret protection Stop leaks before they start
                        + EXPLORE
                            o Why GitHub
                            o Documentation
                            o Blog
                            o Changelog
                            o Marketplace
                      View all features
                * Solutions
                        + BY COMPANY SIZE
                            o Enterprises
                            o Small and medium teams
                            o Startups
                            o Nonprofits
                        + BY USE CASE
                            o App Modernization
                            o DevSecOps
                            o DevOps
                            o CI/CD
                            o View all use cases
                        + BY INDUSTRY
                            o Healthcare
                            o Financial services
                            o Manufacturing
                            o Government
                            o View all industries
                      View all solutions
                * Resources
                        + EXPLORE BY TOPIC
                            o AI
                            o Software Development
                            o DevOps
                            o Security
                            o View all topics
                        + EXPLORE BY TYPE
                            o Customer stories
                            o Events & webinars
                            o Ebooks & reports
                            o Business insights
                            o GitHub Skills
                        + SUPPORT & SERVICES
                            o Documentation
                            o Customer support
                            o Community forum
                            o Trust center
                            o Partners
                      View all resources
                * Open Source
                        + COMMUNITY
                            o GitHub Sponsors Fund open source developers
                        + PROGRAMS
                            o Security Lab
                            o Maintainer Community
                            o Accelerator
                            o GitHub Stars
                            o Archive Program
                        + REPOSITORIES
                            o Topics
                            o Trending
                            o Collections
                * Enterprise
                        + ENTERPRISE SOLUTIONS
                            o Enterprise platform AI-powered developer platform
                        + AVAILABLE ADD-ONS
                            o GitHub Advanced Security Enterprise-grade security features
                            o Copilot for Business Enterprise-grade AI features
                            o Premium Support Enterprise-grade 24/7 support
              * Pricing
                Type / to search
                Sign in
              Sign up Appearance settings
      You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

              Uh oh!

              There was an error while loading. Please reload this page.

              pytest-dev / pytest Public

                      * Uh oh!

                        There was an error while loading. Please reload this page.

              * Notifications You must be signed in to change notification settings
              * Fork 3.3k
                * Star 14.4k
          * Code
          * Issues 685
          * Pull requests 128
          * Discussions
          * Actions
          * Projects
          * Wiki
          * Security and quality 0
          * Insights
          Additional navigation options
                  * Code
                  * Issues
                  * Pull requests
                  * Discussions
                  * Actions
                  * Projects
                  * Wiki
                  * Security and quality
                  * Insights
                                              main
                                          Branches Tags
                                            Go to file
                                        Code
                                          Open more actions menu

                                        Folders and files

                                          Name                             Name                               Last commit message    Last commit date
                                            Latest commit                
                                                                         
                                                History                  
                                                                         
                                                17,606 Commits           
                                                  17,606 Commits         
                                                  .github                          .github                                                           
                                                  bench                            bench                                                             
                                                  changelog                        changelog                                                         
                                                  doc/ en                          doc/ en                                                           
                                                  extra                            extra                                                             
                                                  scripts                          scripts                                                           
                                                  src                              src                                                               
                                                  testing                          testing                                                           
                                                  .git-blame-ignore-revs           .git-blame-ignore-revs                                            
                                                  .gitattributes                   .gitattributes                                                    
                                                  .gitignore                       .gitignore                                                        
                                                  .mailmap                         .mailmap                                                          
                                                  .pre-commit-config.yaml          .pre-commit-config.yaml                                           
                                                  .readthedocs.yaml                .readthedocs.yaml                                                 
                                                  AUTHORS                          AUTHORS                                                           
                                                  CHANGELOG.rst                    CHANGELOG.rst                                                     
                                                  CITATION                         CITATION                                                          
                                                  CODE_OF_CONDUCT.md               CODE_OF_CONDUCT.md                                                
                                                  CONTRIBUTING.rst                 CONTRIBUTING.rst                                                  
                                                  LICENSE                          LICENSE                                                           
                                                  OPENCOLLECTIVE.rst               OPENCOLLECTIVE.rst                                                
                                                  README.rst                       README.rst                                                        
                                                  RELEASING.rst                    RELEASING.rst                                                     
                                                  SECURITY.md                      SECURITY.md                                                       
                                                  TIDELIFT.rst                     TIDELIFT.rst                                                      
                                                  codecov.yml                      codecov.yml                                                       
                                                  pyproject.toml                   pyproject.toml                                                    
                                                  tox.ini                          tox.ini                                                           
                                                  uv.lock                          uv.lock                                                           
                                            View all files               
                                          

                                              Repository files navigation

                                                * 
                                                * README
                                                * Code of conduct
                                                * Contributing
                                                * MIT license
                                                * Security
                                                More items

                                              The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.

                                              An example of a simple test:

                                                # content of test_sample.py
                                                def inc(x):
                                                    return x + 1
                                                
                                                
                                                def test_answer():
                                                    assert inc(3) == 5

                                              To execute it:

                                              $ pytest
                                              ============================= test session starts =============================
                                              collected 1 items
                                              
                                              test_sample.py F
                                              
                                              ================================== FAILURES ===================================
                                              _________________________________ test_answer _________________________________
                                              
                                                  def test_answer():
                                              >       assert inc(3) == 5
                                              E       assert 4 == 5
                                              E        +  where 4 = inc(3)
                                              
                                              test_sample.py:5: AssertionError
                                              ========================== 1 failed in 0.04 seconds ===========================
                                              

                                              Thanks to pytest's detailed assertion introspection, you can simply use plain assert statements. See getting-started for more examples.

                                                Features

                                                * Detailed info on failing assert statements (no need to remember self.assert* names)
                                                * Auto-discovery of test modules and functions
                                                * Modular fixtures for managing small or parametrized long-lived test resources
                                                * Can run unittest (or trial) test suites out of the box
                                                * Python 3.10+ or PyPy3
                                                * Rich plugin architecture, with over 1300+ external plugins and thriving community

                                                Documentation

                                              For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/stable/.

                                                Bugs/Requests

                                              Please use the GitHub issue tracker to submit bugs or request features.

                                                Changelog

                                              Consult the Changelog page for fixes and enhancements of each version.

                                                Support pytest

                                              Open Collective is an online funding platform for open and transparent communities. It provides tools to raise money and share your finances in full transparency.

                                              It is the platform of choice for individuals and companies that want to make one-time or monthly donations directly to the project.

                                              See more details in the pytest collective.

                                                pytest for enterprise

                                              Available as part of the Tidelift Subscription.

                                              The maintainers of pytest and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.

                                              Learn more.

                                                Security

                                              If you have found an issue that you believe is a security vulnerability, please do not create an issue -- instead, report it via a new security advisory.

                                                License

                                              Copyright Holger Krekel and others, 2004.

                                              Distributed under the terms of the MIT license, pytest is free and open source software.

                                        About

                                        The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

                                          pytest.org

                                        Topics

                                          hacktoberfestpythontesttestingunit-testing

                                        Resources

                                          Readme
                                          MIT license

                                        Code of conduct

                                          Code of conduct

                                        Contributing

                                          Contributing

                                        Security policy

                                          Security policy
                                          Cite this repository
                                          Activity
                                          Custom properties

                                        Stars

                                          14.4k stars

                                        Watchers

                                          191 watching

                                        Forks

                                          3.3k forks
                                          Report repository

                                        Releases

                                        Sponsor this project

                                        Used by

                                        Contributors

                                        Languages

    Footer

        © 2026 GitHub, Inc.

      Footer navigation

        * Terms
        * Privacy
        * Security
        * Status
        * Community
        * Docs
        * Contact
        * Manage cookies
        * Do not share my personal information
      You can’t perform that action at this time.