From 461ca12a74403d36fb0c010f7d5c9666baf721f6 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 1 Jan 2022 14:13:11 +0100 Subject: [PATCH] Add devshell command: "update_test_snapshots" --- src/inventory_project/dev_shell.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/inventory_project/dev_shell.py b/src/inventory_project/dev_shell.py index 348e477..3081fd0 100644 --- a/src/inventory_project/dev_shell.py +++ b/src/inventory_project/dev_shell.py @@ -184,6 +184,21 @@ class PyInventoryCommandSet(DevShellBaseCommandSet): print(f'updated: {po_file_path}') + def do_update_test_snapshots(self, statement: cmd2.Statement): + """ + Update all test snapshot files by run tests with RAISE_SNAPSHOT_ERRORS=0 + """ + verbose_check_call( + 'pytest', + *statement.arg_list, + cwd=self.config.base_path, + exit_on_error=True, + extra_env={ + # https://github.com/boxine/bx_py_utils#notes-about-snapshot + 'RAISE_SNAPSHOT_ERRORS': '0' + } + ) + class DevShellCommandSet(OriginDevShellCommandSet):