def test_checkout_branch(): try: git.branch('-D', 'issue/42/foo-bar') except: pass args = Problem.default_args() args.issue = 42 args.name = 'foo-bar' p = Problem(args) p.checkout_branch() actual_branch_name = '{}'.format(repo.active_branch) expected_branch_name = 'issue/{}/{}'.format(args.issue, args.name) git.checkout(initial_branch) try: git.branch('-D', expected_branch_name) except: pass assert (actual_branch_name == expected_branch_name)