def test_canonical_path_absolute(self): """Test creating canonical path.""" if platform.system() == "Windows": original_path = "D:\\hello\\world.txt" res = File.canonical_path(original_path) self.assertEqual(res, "d:\\hello\\world.txt") else: original_path = "/hello/world.txt" res = File.canonical_path(original_path) self.assertEqual(res, "/hello/world.txt")
def test_find_file(self): """Test if we can find a file.""" current_folder = path.dirname(path.abspath(__file__)) parent_folder = path.dirname(current_folder) file = File.search(file_name='README.md', from_folder=current_folder, to_folder=parent_folder) expected = path.join(parent_folder, 'README.md') self.assertTrue(file.loaded()) self.assertEqual(file.full_path(), expected)
def test_canonical_path_empty(self): """Test failing for canonical path.""" original_path = None res = File.canonical_path(original_path) self.assertIsNone(res)