From 2a59e1bcb772fbd898239f7fb970e5dcbbd1cf2a Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 8 Aug 2021 19:25:44 +0200 Subject: [PATCH] [test] Introduce click context helper --- tests/helpers.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/helpers.py diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 00000000..5c1fc0bb --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,26 @@ +# Copyright 2016-2021 Maël Azimi <m.a@moul.re> +# +# Silkaj is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Silkaj is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. + +import click + +from silkaj import cli + + +def define_click_context(endpoint=None, gtest=False): + ctx = click.Context(cli.cli) + ctx.obj = dict() + ctx.obj["ENDPOINT"] = endpoint + ctx.obj["GTEST"] = gtest + click.globals.push_context(ctx) -- GitLab