Skip to main content

PackTest

This module is designed to provide a strictly in-code implementation of MetaPathFinder that can be leveraged in unit testing in order to simulate an entry point being created, as would be loaded by importlib.metadata.entry_points() in Python 3.8+ or by importlib_metadata.entry_points() in earlier versions.

If there are requests, additional functionality aimed at testing plugin packages may be added in future releases.

Usage

import unittest
import packtest

class Test(unittest.TestCase):

    def test_me(self):
        # Could move some of this to be a test fixture instead
        
        # Finder on sys.meta_path
        finder = packtest.TestFinder()
        
        # Add it to sys.meta_path
        finder.register()
        
        # Create a package
        package = packtest.TestPackage("foobar")
        
        # Create entry points
        package.add_entry_point(
            # Equivalent to a module with the following in setup.cfg:
            # [options.entry_points]
            # myep.group = 
            #     foobar = myep.tests:test.attr  
            packtest.TestEntryPoint("foobar", "myep.group", "myep.tests", "test.attr")
        )

        package.add_entry_point(
            # Equivalent to a module with the following in setup.cfg:
            # [options.entry_points]
            # myep.group = 
            #     foobar2 = myep.tests:test.attr[bar]  
            packtest.TestEntryPoint("foobar2", "myep.group", "myep.tests", "test.attr", ["bar"])
        )
        finder.add_package(package)

        # ... do testsConsultationClassesIslandOfferings2
        
        # Call this to remove your foobar test package
        finder.remove_package(package)

        # Remove all packages
        finder.clear()
        
        # It is necessary to clean up sys.meta_path after your test case with this:
        finder.unregister()

Metadata

Release files for pack-test 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pack-test 0.1.0
File Interpreter ABI Platform Actions
pack_test-0.1.0-py3-none-any.whl Python 3 none any Details for pack_test-0.1.0-py3-none-any.whl

Release files / pack_test-0.1.0-py3-none-any.whl

Download URL pack_test-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e56daada9eaf0ca55505d45f8275babee6449ccecd6133ef8bb4bd010eafa2a
BLAKE2b-256 checksum
How to use checksums
09e25530206902c107218717da8c992398dfb419687eb67dd51d1f90295c8b0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.9

Security for pack-test 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page