How to use is_symlink method in lisa

Best Python code snippet using lisa_python

test_sevenzip.py

Source:test_sevenzip.py Github

copy

Full Screen

1#2# Copyright (c) 2015 nexB Inc. and others. All rights reserved.3# http://nexb.com and https://github.com/nexB/scancode-toolkit/4# The ScanCode software is licensed under the Apache License version 2.0.5# Data generated with ScanCode require an acknowledgment.6# ScanCode is a trademark of nexB Inc.7#8# You may not use this software except in compliance with the License.9# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.010# Unless required by applicable law or agreed to in writing, software distributed11# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR12# CONDITIONS OF ANY KIND, either express or implied. See the License for the13# specific language governing permissions and limitations under the License.14#15# When you publish or redistribute any data created with ScanCode or any ScanCode16# derivative work, you must accompany this data with the following acknowledgment:17#18# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES19# OR CONDITIONS OF ANY KIND, either express or implied. No content created from20# ScanCode should be considered or used as legal advice. Consult an Attorney21# for any legal advice.22# ScanCode is a free software code scanning tool from nexB Inc. and others.23# Visit https://github.com/nexB/scancode-toolkit/ for support and download.24from __future__ import absolute_import, print_function25import os26from commoncode.testcase import FileBasedTesting27from extractcode import sevenzip28class TestSevenZip(FileBasedTesting):29 test_data_dir = os.path.join(os.path.dirname(__file__), 'data')30 def test_get_7z_errors_password_protected(self):31 test = '''327-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-3033Processing archive: c:\w421\scripts\testfiles\archive\zip\zip_password_nexb.zip34Extracting a.txt CRC Failed in encrypted file. Wrong password?35Sub items Errors: 136'''37 result = sevenzip.get_7z_errors(test)38 expected = 'Password protected archive, unable to extract'39 assert expected == result40 def test__list_extracted_7z_files_empty(self):41 assert [] == sevenzip.list_extracted_7z_files('')42 def test__list_extracted_7z_files_2(self):43 test = '''447-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30'45p7zip Version 9.04 (locale=utf8,Utf16=on,HugeFiles=on,2 CPUs)46Processing archive: /tmp/a.rpm47Extracting a.cpio48Everything is Ok49Size: 653650Compressed: 767451'''52 expected = ['a.cpio']53 result = sevenzip.list_extracted_7z_files(test)54 assert expected == result55 def test__list_extracted_7z_files_3(self):56 test = '''577-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-3058p7zip Version 9.04 (locale=utf8,Utf16=on,HugeFiles=on,2 CPUs)59Processing archive: /tmp/a.rpm60Extracting a.cpio61Extracting b.cpio62Everything is Ok63Size: 653664Compressed: 767465'''66 expected = ['a.cpio', 'b.cpio']67 result = sevenzip.list_extracted_7z_files(test)68 assert expected == result69 def test_list_sevenzip_on_tar(self):70 test_file = self.get_test_loc('archive/tar/special.tar')71 expected = [72 dict(path=u'0-REGTYPE', size=u'3765', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),73 dict(path=u'0-REGTYPE-TEXT', size=u'19941', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),74 dict(path=u'0-REGTYPE-VEEEERY_LONG_NAME_____________________________________________________________________________________________________________________155', size=u'3765', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),75 dict(path=u'1-LNKTYPE', size=u'0', is_file=True, is_dir=False, is_hardlink=True, is_symlink=False, link_target=u'0-REGTYPE', is_broken_link=False, is_special=False),76 dict(path=u'2-SYMTYPE', size=u'17', is_file=True, is_dir=False, is_hardlink=False, is_symlink=True, link_target=u'testtar/0-REGTYPE', is_broken_link=False, is_special=False),77 dict(path=u'3-CHRTYPE', size=u'0', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),78 dict(path=u'5-DIRTYPE', size=u'0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),79 dict(path=u'6-FIFOTYPE', size=u'0', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),80 dict(path=u'S-SPARSE', size=u'49152', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),81 dict(path=u'S-SPARSE-WITH-NULLS', size=u'49152', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False)82 ]83 result = [e.asdict() for e in sevenzip.list_entries(test_file)]84 assert expected == result85 def test_parse_7z_listing_linux(self):86 test_file = self.get_test_loc('archive/7z/listings/cpio_relative.cpio.linux')87 expected = [88 dict(path='../..', size='0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),89 dict(path='../../2folder', size='0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),90 dict(path='../../2folder/3folder', size='0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),91 dict(path='../../2folder/3folder/cpio_relative.cpio', size='0', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),92 dict(path='../../2folder/3folder/relative_file', size='14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),93 dict(path='../../2folder/3folder/relative_file~', size='14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),94 dict(path='../../2folder/relative_file', size='14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),95 dict(path='../../relative_file', size='14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False)96 ]97 result = [e.asdict() for e in sevenzip.parse_7z_listing(test_file, False)]98 assert expected == result99 def test_parse_7z_listing_win(self):100 test_file = self.get_test_loc('archive/7z/listings/cpio_relative.cpio.win')101 expected = [102 dict(path=u'..\\..', size=u'0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),103 dict(path=u'..\\..\\2folder', size=u'0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),104 dict(path=u'..\\..\\2folder\\3folder', size=u'0', is_file=False, is_dir=True, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),105 dict(path=u'..\\..\\2folder\\3folder\\cpio_relative.cpio', size=u'0', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),106 dict(path=u'..\\..\\2folder\\3folder\\relative_file', size=u'14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),107 dict(path=u'..\\..\\2folder\\3folder\\relative_file~', size=u'14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),108 dict(path=u'..\\..\\2folder\\relative_file', size=u'14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False),109 dict(path=u'..\\..\\relative_file', size=u'14', is_file=True, is_dir=False, is_hardlink=False, is_symlink=False, link_target=None, is_broken_link=False, is_special=False)110 ]111 result = [e.asdict() for e in sevenzip.parse_7z_listing(test_file, True)]...

Full Screen

Full Screen

image.py

Source:image.py Github

copy

Full Screen

...26 if container is None:27 print(f"No image with identifier '{uri_or_alias}' found")28 return 129 path = singularity_dir.uris / container.uri_path30 if not path.is_symlink() and not purge:31 print(32 f"The uri {container.uri}' is directly attached to it's data and cannot "33 "be removed without the --purge flag."34 )35 return 136 if path.is_symlink() and purge:37 print("[INFO] The purge flag is not yet implemented in this context.")38 for snakemake_alias in singularity_dir.snakemake.iterdir():39 if snakemake_alias.is_symlink() and path.samefile(snakemake_alias):40 snakemake_alias.unlink()41 if path.is_symlink():42 snakemake_alias.symlink_to(os.readlink(path))43 for alias in singularity_dir.aliases.iterdir():44 if alias.is_symlink() and path.samefile(alias):45 alias.unlink()46 if uri_or_alias != alias.name:47 print(f"Removing alias '{alias.name}'")48 if path.is_symlink():49 path.unlink()50 else:51 os.remove(path)52@attrs.frozen53class _ImgListModel:54 command: Subcommand = subcommand(55 commands={56 "list": _list.cli,57 "rm": _rm.cli,58 },59 )60@command61def img_cmd(cmd_name: str, args: _ImgListModel, tail: list[str]):62 """Interact with container image files"""...

Full Screen

Full Screen

test_scandir.py

Source:test_scandir.py Github

copy

Full Screen

...12 self.assertEqual(ent.path, os.path.join(testdata_dir, ent.name))13 if ent.name == 'test_file':14 self.assertTrue(ent.is_file())15 self.assertFalse(ent.is_dir())16 self.assertFalse(ent.is_symlink())17 elif ent.name == 'test_dir':18 self.assertFalse(ent.is_file())19 self.assertTrue(ent.is_dir())20 self.assertFalse(ent.is_symlink())21 elif ent.name == 'link_test_file':22 self.assertTrue(ent.is_file())23 self.assertFalse(ent.is_file(follow_symlinks=False))24 self.assertFalse(ent.is_dir())25 self.assertFalse(ent.is_dir(follow_symlinks=False))26 self.assertTrue(ent.is_symlink())27 elif ent.name == 'link_test_dir':28 self.assertFalse(ent.is_file())29 self.assertFalse(ent.is_file(follow_symlinks=False))30 self.assertTrue(ent.is_dir())31 self.assertFalse(ent.is_dir(follow_symlinks=False))32 self.assertTrue(ent.is_symlink())33 elif ent.name == 'link_does_not_exist':34 self.assertFalse(ent.is_file())35 self.assertFalse(ent.is_file(follow_symlinks=False))36 self.assertFalse(ent.is_dir())37 self.assertFalse(ent.is_dir(follow_symlinks=False))38 self.assertTrue(ent.is_symlink())39 else:40 self.fail('unexpected filename: ' + ent.name)...

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