Best Python code snippet using avocado_python
filesystem.py
Source:filesystem.py
...65 """Test copying to an existing directory."""66 with fs.working_dir(str(stage)):67 fs.copy_tree('source', 'dest')68 assert os.path.exists('dest/a/b/2')69 def test_non_existing_dir(self, stage):70 """Test copying to a non-existing directory."""71 with fs.working_dir(str(stage)):72 fs.copy_tree('source', 'dest/sub/directory')73 assert os.path.exists('dest/sub/directory/a/b/2')74 def test_symlinks_true(self, stage):75 """Test copying with symlink preservation."""76 with fs.working_dir(str(stage)):77 fs.copy_tree('source', 'dest', symlinks=True)78 assert os.path.exists('dest/2')79 assert os.path.islink('dest/2')80 assert os.path.exists('dest/a/b2')81 with fs.working_dir('dest/a'):82 assert os.path.exists(os.readlink('b2'))83 assert (os.path.realpath('dest/f/2') ==84 os.path.abspath('dest/a/b/2'))85 assert os.path.realpath('dest/2') == os.path.abspath('dest/1')86 def test_symlinks_true_ignore(self, stage):87 """Test copying when specifying relative paths that should be ignored88 """89 with fs.working_dir(str(stage)):90 ignore = lambda p: p in ['c/d/e', 'a']91 fs.copy_tree('source', 'dest', symlinks=True, ignore=ignore)92 assert not os.path.exists('dest/a')93 assert os.path.exists('dest/c/d')94 assert not os.path.exists('dest/c/d/e')95 def test_symlinks_false(self, stage):96 """Test copying without symlink preservation."""97 with fs.working_dir(str(stage)):98 fs.copy_tree('source', 'dest', symlinks=False)99 assert os.path.exists('dest/2')100 assert not os.path.islink('dest/2')101class TestInstallTree:102 """Tests for ``filesystem.install_tree``"""103 def test_existing_dir(self, stage):104 """Test installing to an existing directory."""105 with fs.working_dir(str(stage)):106 fs.install_tree('source', 'dest')107 assert os.path.exists('dest/a/b/2')108 def test_non_existing_dir(self, stage):109 """Test installing to a non-existing directory."""110 with fs.working_dir(str(stage)):111 fs.install_tree('source', 'dest/sub/directory')112 assert os.path.exists('dest/sub/directory/a/b/2')113 def test_symlinks_true(self, stage):114 """Test installing with symlink preservation."""115 with fs.working_dir(str(stage)):116 fs.install_tree('source', 'dest', symlinks=True)117 assert os.path.exists('dest/2')118 assert os.path.islink('dest/2')119 def test_symlinks_false(self, stage):120 """Test installing without symlink preservation."""121 with fs.working_dir(str(stage)):122 fs.install_tree('source', 'dest', symlinks=False)...
test_backup.py
Source:test_backup.py
...56 assert (d / f"{image_file.basename}.{n:02d}").read() == f"{CONTENT} - {NUM - n}"57 assert (d / f"{image_file.basename}.{(n + 1):02d}").read() == f"{CONTENT} - {NUM - n - 2}"585960def test_non_existing_dir():
...
test_sensors.py
Source:test_sensors.py
...20 task_id="file_sensor",21 dag=test_dag22 )23 assert not task.poke({})24 def test_non_existing_dir(self, local_mock_dir, test_dag):25 """Tests example with non-existing dir."""26 task = sensors.FileSensor(27 path=posixpath.join(local_mock_dir, "non_existing_dir", "*.xml"),28 hook=LocalHook(),29 task_id="file_sensor",30 dag=test_dag31 )...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!