Test suite enhancement for testing plugins
Project description
Entry Point Testing
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.
Requests for additional functionality aimed at testing plugin packages will be considered.
Usage
import unittest
import eptest
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 = eptest.TestFinder()
# Add it to sys.meta_path
finder.register()
# Create a package
package = eptest.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
eptest.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]
eptest.TestEntryPoint("foobar2", "myep.group", "myep.tests", "test.attr", ["bar"])
)
finder.add_package(package)
# ... do tests
# 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 Distribution
eptest-0.1.1.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file eptest-0.1.1.tar.gz
.
File metadata
- Download URL: eptest-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e705de418728295d176e3dc9fa0f2bac445f357467c6ac15f83da8b184c7a86 |
|
MD5 | a0a4b17f4e556570b173a1665f935cf5 |
|
BLAKE2b-256 | 29a5ad807d4a8451fedbdd056359b7930e5ab9012dede87b84c953d9e4310c09 |
File details
Details for the file eptest-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: eptest-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 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 | 158dd9ae69f5ff7f02a03cd8256c98124bf9d173adb83e31776246c352b17518 |
|
MD5 | c5fe51aaa40fd3532d9ceaa40176ce00 |
|
BLAKE2b-256 | e7eb197060da627d13d071f01befa49cf5988136f7864f9672160e3ab7720ea1 |