How to use test_check_exists method in autotest

Best Python code snippet using autotest_python

test_fs.py

Source:test_fs.py Github

copy

Full Screen

...19from tripleo.utils.fs import Dir, File20class TestDir(TestCase):21 """Tests for :class:`Dir`.22 """23 def test_check_exists(self):24 """Check that an error is thrown if the directory does not exist.25 """26 directory = Dir('some/made/up/path')27 with self.assertRaises(IOError):28 directory.check_exists()29 def test_exists(self):30 """Checks that this tells that the path points to a folder which31 exists.32 """33 with TemporaryDirectory() as path:34 directory = Dir(path)35 self.assertTrue(directory.exists())36 def test_not_exists(self):37 """Checks that it can tell if the directory exists.38 """39 directory = Dir('some/made/up/path')40 self.assertFalse(directory.exists())41 def test_not_directory(self):42 """Checks that it can tell if a path is not a directory.43 """44 with NamedTemporaryFile() as buffer:45 directory = Dir(buffer.name)46 self.assertFalse(directory.exists())47 def test_dir_is_empty(self):48 """Checks that this can tell whether the directory has files in it49 or not.50 """51 with TemporaryDirectory() as folder:52 directory = Dir(folder)53 self.assertTrue(directory.is_empty())54 with NamedTemporaryFile(dir=directory):55 self.assertFalse(directory.is_empty())56 def test_cd(self):57 """Checks that a path to a subdirectory is created as expected.58 """59 subfolder = 'folder'60 with TemporaryDirectory() as folder:61 directory = Dir(folder)62 self.assertEqual(63 f'{directory}/{subfolder}',64 directory.cd(subfolder)65 )66 def test_mkdir_error(self):67 """Checks that an error is raised if the directory's parents do not68 exist.69 """70 directory = Dir('path/to/some/dir')71 with self.assertRaises(FileNotFoundError):72 directory.mkdir(recursive=False)73 def test_simple_mkdir(self):74 """Checks that a folder can be created under a parent directory.75 """76 with TemporaryDirectory() as folder:77 directory = Dir(f'{folder}/dir')78 self.assertFalse(directory.exists())79 directory.mkdir(recursive=False)80 self.assertTrue(directory.exists())81 def test_recursive_mkdir(self):82 """Checks that all the folders leading to a directory can be83 created.84 """85 with TemporaryDirectory() as folder:86 directory = Dir(f'{folder}/dir/subdir')87 self.assertFalse(directory.exists())88 directory.mkdir(recursive=True)89 self.assertTrue(directory.exists())90 @skip(reason='Will fail on CI')91 def test_rm(self):92 """Checks that it is possible to delete the folder and everything93 inside.94 """95 with TemporaryDirectory() as folder:96 directory = Dir(folder)97 self.assertTrue(directory.exists())98 directory.rm()99 self.assertFalse(directory.exists())100 def test_as_path(self):101 """Checks that the type can be converted into a path.102 """103 path = Path('path/to/dir')104 directory = Dir(path)105 self.assertEqual(path, directory.as_path())106 def test_str(self):107 """Checks that the type can be converted into a string through __str__.108 """109 path = 'path/to/dir'110 directory = Dir(path)111 self.assertEqual(path, str(directory))112class TestFile(TestCase):113 """Tests for :class:`File`.114 """115 def test_check_exists(self):116 """Checks that an error is thrown if the file does not exist.117 """118 file = File('some/path/to/a/file')119 with self.assertRaises(IOError):120 file.check_exists()121 def test_exists(self):122 """Checks that this is able to tell whether a file exists on the123 filesystem or not.124 """125 with NamedTemporaryFile() as buffer:126 file = File(buffer.name)127 self.assertTrue(file.exists())128 def test_not_file(self):129 """Checks that it can tell if a path is a file or not....

Full Screen

Full Screen

test_config.py

Source:test_config.py Github

copy

Full Screen

1import os2import pytest3import bugtracker4def test_check_exists():5 """6 Check if the config file exists.7 """8 config_path = "../apps/bugtracker.json"9 assert os.path.isfile(config_path)10def test_fields():11 """12 Check all fields exist.13 Check that all folders exist.14 """15 config_path = "../apps/bugtracker.json"16 config = bugtracker.config.load(config_path)17 folders = ["plot_dir", "netcdf_dir", "cache_dir", "animation_dir"]18 for folder in folders:...

Full Screen

Full Screen

run_test.py

Source:run_test.py Github

copy

Full Screen

1from tests import test_plot, test_emoji2# test_plot.test_plot()3test_emoji.test_check_exists()...

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