How to use test_symlink method in green

Best Python code snippet using green

destroyed_symlinks_test.py

Source:destroyed_symlinks_test.py Github

copy

Full Screen

1import os2import subprocess3import pytest4from pre_commit_hooks.destroyed_symlinks import find_destroyed_symlinks5from pre_commit_hooks.destroyed_symlinks import main6TEST_SYMLINK = 'test_symlink'7TEST_SYMLINK_TARGET = '/doesnt/really/matters'8TEST_FILE = 'test_file'9TEST_FILE_RENAMED = f'{TEST_FILE}_renamed'10@pytest.fixture11def repo_with_destroyed_symlink(tmpdir):12 source_repo = tmpdir.join('src')13 os.makedirs(source_repo, exist_ok=True)14 test_repo = tmpdir.join('test')15 with source_repo.as_cwd():16 subprocess.check_call(('git', 'init'))17 os.symlink(TEST_SYMLINK_TARGET, TEST_SYMLINK)18 with open(TEST_FILE, 'w') as f:19 print('some random content', file=f)20 subprocess.check_call(('git', 'add', '.'))21 subprocess.check_call(22 ('git', 'commit', '--no-gpg-sign', '-m', 'initial'),23 )24 assert b'120000 ' in subprocess.check_output(25 ('git', 'cat-file', '-p', 'HEAD^{tree}'),26 )27 subprocess.check_call(28 ('git', '-c', 'core.symlinks=false', 'clone', source_repo, test_repo),29 )30 with test_repo.as_cwd():31 subprocess.check_call(32 ('git', 'config', '--local', 'core.symlinks', 'true'),33 )34 subprocess.check_call(('git', 'mv', TEST_FILE, TEST_FILE_RENAMED))35 assert not os.path.islink(test_repo.join(TEST_SYMLINK))36 yield test_repo37def test_find_destroyed_symlinks(repo_with_destroyed_symlink):38 with repo_with_destroyed_symlink.as_cwd():39 assert find_destroyed_symlinks([]) == []40 assert main([]) == 041 subprocess.check_call(('git', 'add', TEST_SYMLINK))42 assert find_destroyed_symlinks([TEST_SYMLINK]) == [TEST_SYMLINK]43 assert find_destroyed_symlinks([]) == []44 assert main([]) == 045 assert find_destroyed_symlinks([TEST_FILE_RENAMED, TEST_FILE]) == []46 ALL_STAGED = [TEST_SYMLINK, TEST_FILE_RENAMED]47 assert find_destroyed_symlinks(ALL_STAGED) == [TEST_SYMLINK]48 assert main(ALL_STAGED) != 049 with open(TEST_SYMLINK, 'a') as f:50 print(file=f) # add trailing newline51 subprocess.check_call(['git', 'add', TEST_SYMLINK])52 assert find_destroyed_symlinks(ALL_STAGED) == [TEST_SYMLINK]53 assert main(ALL_STAGED) != 054 with open(TEST_SYMLINK, 'w') as f:55 print('0' * len(TEST_SYMLINK_TARGET), file=f)56 subprocess.check_call(('git', 'add', TEST_SYMLINK))57 assert find_destroyed_symlinks(ALL_STAGED) == []58 assert main(ALL_STAGED) == 059 with open(TEST_SYMLINK, 'w') as f:60 print('0' * (len(TEST_SYMLINK_TARGET) + 3), file=f)61 subprocess.check_call(('git', 'add', TEST_SYMLINK))62 assert find_destroyed_symlinks(ALL_STAGED) == []...

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 green 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