How to use get_upstream method in tox

Best Python code snippet using tox_python

commit_in_branch_test.py

Source:commit_in_branch_test.py Github

copy

Full Screen

...7 branch_has_backport_of_commit,8 canonicalize_commit,9 validate_branch,10)11def get_upstream() -> str:12 # Let's assume master is bound to the upstream remote and not a fork13 out = subprocess.check_output(['git', 'for-each-ref',14 '--format=%(upstream)',15 'refs/heads/master'],16 stderr=subprocess.DEVNULL)17 return out.decode().strip().split('/')[2]18@pytest.mark.parametrize(19 'commit, expected',20 [21 ('20.1-branchpoint', True),22 ('master', True),23 ('e58a10af640ba58b6001f5c5ad750b782547da76', True),24 ('d043d24654c851f0be57dbbf48274b5373dea42b', True),25 ('dd2bd68fa69124c86cd008b256d06f44fab8e6cd', True),26 ('0000000000000000000000000000000000000000', False),27 ('not-even-a-valid-commit-format', False),28 ])29def test_canonicalize_commit(commit: str, expected: bool) -> None:30 if expected:31 assert canonicalize_commit(commit)32 else:33 try:34 assert canonicalize_commit(commit)35 except argparse.ArgumentTypeError:36 return37 assert False38@pytest.mark.parametrize(39 'commit, expected',40 [41 (get_upstream() + '/20.1', True),42 (get_upstream() + '/master', True),43 ('20.1', False),44 ('master', False),45 ('e58a10af640ba58b6001f5c5ad750b782547da76', False),46 ('d043d24654c851f0be57dbbf48274b5373dea42b', False),47 ('dd2bd68fa69124c86cd008b256d06f44fab8e6cd', False),48 ('0000000000000000000000000000000000000000', False),49 ('not-even-a-valid-commit-format', False),50 ])51def test_validate_branch(commit: str, expected: bool) -> None:52 if expected:53 assert validate_branch(commit)54 else:55 try:56 assert validate_branch(commit)57 except argparse.ArgumentTypeError:58 return59 assert False60@pytest.mark.parametrize(61 'commit, expected',62 [63 ('master', True),64 ('20.1-branchpoint', True),65 ('20.1', False),66 (get_upstream() + '/20.1', True),67 ('e58a10af640ba58b6001f5c5ad750b782547da76', True),68 ('d043d24654c851f0be57dbbf48274b5373dea42b', True),69 ('dd2bd68fa69124c86cd008b256d06f44fab8e6cd', True),70 ('0000000000000000000000000000000000000000', False),71 ('not-even-a-valid-commit-format', False),72 ])73def test_is_commit_valid(commit: str, expected: bool) -> None:74 assert is_commit_valid(commit) == expected75@pytest.mark.parametrize(76 'branch, commit, expected',77 [78 ('20.1', '20.1-branchpoint', True),79 ('20.1', '20.0', False),80 ('20.1', 'master', False),81 ('20.1', 'e58a10af640ba58b6001f5c5ad750b782547da76', True),82 ('20.1', 'd043d24654c851f0be57dbbf48274b5373dea42b', True),83 ('20.1', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', False),84 ('master', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', True),85 ('20.0', 'd043d24654c851f0be57dbbf48274b5373dea42b', False),86 ])87def test_branch_has_commit(branch: str, commit: str, expected: bool) -> None:88 upstream = get_upstream()89 assert branch_has_commit(upstream, branch, commit) == expected90@pytest.mark.parametrize(91 'branch, commit, expected',92 [93 ('20.1', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', 'd043d24654c851f0be57dbbf48274b5373dea42b'),94 ('20.1', '20.1-branchpoint', ''),95 ('20.1', '20.0', ''),96 ('20.1', '20.2', ''),97 ('20.1', 'master', ''),98 ('20.1', 'd043d24654c851f0be57dbbf48274b5373dea42b', ''),99 ('20.0', 'dd2bd68fa69124c86cd008b256d06f44fab8e6cd', ''),100 ])101def test_branch_has_backport_of_commit(branch: str, commit: str, expected: bool) -> None:102 upstream = get_upstream()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful