mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-14 09:15:54 -04:00
test: replace pkg_resources call
This commit is contained in:
parent
418758fc22
commit
42210907f5
1 changed files with 14 additions and 4 deletions
|
@ -18,14 +18,24 @@ limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import brozzler.cli
|
import brozzler.cli
|
||||||
import pkg_resources
|
import importlib.metadata
|
||||||
import pytest
|
import pytest
|
||||||
import subprocess
|
import subprocess
|
||||||
import doublethink
|
import doublethink
|
||||||
|
|
||||||
|
|
||||||
|
def console_scripts():
|
||||||
|
# We do a dict comprehension here because the select filters aren't
|
||||||
|
# available until Python 3.10's importlib.
|
||||||
|
return {
|
||||||
|
ep.name: ep
|
||||||
|
for ep in importlib.metadata.distribution("brozzler").entry_points
|
||||||
|
if ep.group == "console_scripts"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def cli_commands():
|
def cli_commands():
|
||||||
commands = set(pkg_resources.get_entry_map("brozzler")["console_scripts"].keys())
|
commands = set(console_scripts().keys())
|
||||||
commands.remove("brozzler-wayback")
|
commands.remove("brozzler-wayback")
|
||||||
try:
|
try:
|
||||||
import gunicorn
|
import gunicorn
|
||||||
|
@ -40,8 +50,8 @@ def cli_commands():
|
||||||
|
|
||||||
@pytest.mark.parametrize("cmd", cli_commands())
|
@pytest.mark.parametrize("cmd", cli_commands())
|
||||||
def test_call_entrypoint(capsys, cmd):
|
def test_call_entrypoint(capsys, cmd):
|
||||||
entrypoint = pkg_resources.get_entry_map("brozzler")["console_scripts"][cmd]
|
entrypoint = console_scripts()[cmd]
|
||||||
callable = entrypoint.resolve()
|
callable = entrypoint.load()
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
callable(["/whatever/bin/%s" % cmd, "--version"])
|
callable(["/whatever/bin/%s" % cmd, "--version"])
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue