Test suite enhancement for testing plugins
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file pack_test-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pack_test-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e56daada9eaf0ca55505d45f8275babee6449ccecd6133ef8bb4bd010eafa2a |
|
MD5 | e1bd72b6999274befe58f58e287da289 |
|
BLAKE2b-256 | 09e25530206902c107218717da8c992398dfb419687eb67dd51d1f90295c8b0d |