More robust _called_from_test pattern

This commit is contained in:
Simon Willison 2023-07-22 16:21:27 -07:00
commit 778dad789e
2 changed files with 3 additions and 2 deletions

View file

@ -3106,7 +3106,8 @@ def plugins_list():
click.echo(json.dumps(get_plugins(), indent=2))
pm.hook.register_commands(cli=cli)
if not getattr(sys, "_called_from_test", False):
pm.hook.register_commands(cli=cli)
def _render_common(title, values):

View file

@ -5,7 +5,7 @@ from . import hookspecs
pm = pluggy.PluginManager("sqlite_utils")
pm.add_hookspecs(hookspecs)
if not hasattr(sys, "_called_from_test"):
if not getattr(sys, "_called_from_test", False):
# Only load plugins if not running tests
pm.load_setuptools_entrypoints("sqlite_utils")