use depyler_core::transpile_python_to_rust;
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_constructor() {
let python = r#"
from pathlib import Path
def create_path(s: str) -> Path:
return Path(s)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("PathBuf") || result.contains("Path::new"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_join() {
let python = r#"
from pathlib import Path
def join_paths(base: str, part: str) -> Path:
return Path(base) / part
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("join") || result.contains("/"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_name() {
let python = r#"
from pathlib import Path
def get_name(p: Path) -> str:
return p.name
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("file_name") || result.contains("name"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_stem() {
let python = r#"
from pathlib import Path
def get_stem(p: Path) -> str:
return p.stem
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("file_stem") || result.contains("stem"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_suffix() {
let python = r#"
from pathlib import Path
def get_suffix(p: Path) -> str:
return p.suffix
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("extension") || result.contains("suffix"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_parent() {
let python = r#"
from pathlib import Path
def get_parent(p: Path) -> Path:
return p.parent
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("parent"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_parents() {
let python = r#"
from pathlib import Path
def get_parents(p: Path) -> list:
return list(p.parents)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("ancestors") || result.contains("parents"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_exists() {
let python = r#"
from pathlib import Path
def check_exists(p: Path) -> bool:
return p.exists()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("exists"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_is_file() {
let python = r#"
from pathlib import Path
def check_is_file(p: Path) -> bool:
return p.is_file()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("is_file"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_is_dir() {
let python = r#"
from pathlib import Path
def check_is_dir(p: Path) -> bool:
return p.is_dir()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("is_dir"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_is_absolute() {
let python = r#"
from pathlib import Path
def check_is_absolute(p: Path) -> bool:
return p.is_absolute()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("is_absolute"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_is_relative_to() {
let python = r#"
from pathlib import Path
def check_is_relative_to(p: Path, other: Path) -> bool:
return p.is_relative_to(other)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("starts_with") || result.contains("is_relative_to"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_absolute() {
let python = r#"
from pathlib import Path
def make_absolute(p: Path) -> Path:
return p.absolute()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("canonicalize") || result.contains("absolute"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_resolve() {
let python = r#"
from pathlib import Path
def resolve_path(p: Path) -> Path:
return p.resolve()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("canonicalize") || result.contains("resolve"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_with_name() {
let python = r#"
from pathlib import Path
def replace_name(p: Path, name: str) -> Path:
return p.with_name(name)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("with_file_name") || result.contains("with_name"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_with_suffix() {
let python = r#"
from pathlib import Path
def replace_suffix(p: Path, suffix: str) -> Path:
return p.with_suffix(suffix)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("with_extension") || result.contains("with_suffix"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_with_stem() {
let python = r#"
from pathlib import Path
def replace_stem(p: Path, stem: str) -> Path:
return p.with_stem(stem)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("with_file_name") || result.contains("stem"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_mkdir() {
let python = r#"
from pathlib import Path
def create_dir(p: Path) -> None:
p.mkdir()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("create_dir") || result.contains("mkdir"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_mkdir_parents() {
let python = r#"
from pathlib import Path
def create_dir_parents(p: Path) -> None:
p.mkdir(parents=True)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("create_dir_all") || result.contains("parents"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_rmdir() {
let python = r#"
from pathlib import Path
def remove_dir(p: Path) -> None:
p.rmdir()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("remove_dir") || result.contains("rmdir"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_iterdir() {
let python = r#"
from pathlib import Path
def list_dir(p: Path) -> list:
return list(p.iterdir())
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("read_dir") || result.contains("iterdir"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_glob() {
let python = r#"
from pathlib import Path
def find_files(p: Path, pattern: str) -> list:
return list(p.glob(pattern))
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("glob") || result.contains("pattern"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_rglob() {
let python = r#"
from pathlib import Path
def find_files_recursive(p: Path, pattern: str) -> list:
return list(p.rglob(pattern))
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("glob") || result.contains("recursive"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_read_text() {
let python = r#"
from pathlib import Path
def read_file(p: Path) -> str:
return p.read_text()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("read_to_string") || result.contains("read_text"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_read_bytes() {
let python = r#"
from pathlib import Path
def read_file_bytes(p: Path) -> bytes:
return p.read_bytes()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("read") || result.contains("read_bytes"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_write_text() {
let python = r#"
from pathlib import Path
def write_file(p: Path, content: str) -> None:
p.write_text(content)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("write") || result.contains("write_text"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_write_bytes() {
let python = r#"
from pathlib import Path
def write_file_bytes(p: Path, content: bytes) -> None:
p.write_bytes(content)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("write") || result.contains("write_bytes"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_unlink() {
let python = r#"
from pathlib import Path
def delete_file(p: Path) -> None:
p.unlink()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("remove_file") || result.contains("unlink"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_rename() {
let python = r#"
from pathlib import Path
def rename_file(p: Path, new_name: str) -> Path:
return p.rename(new_name)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("rename") || result.contains("move"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_as_posix() {
let python = r#"
from pathlib import Path
def to_posix(p: Path) -> str:
return p.as_posix()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("to_str") || result.contains("as_posix"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_as_uri() {
let python = r#"
from pathlib import Path
def to_uri(p: Path) -> str:
return p.as_uri()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("uri") || result.contains("url"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_str_conversion() {
let python = r#"
from pathlib import Path
def to_string(p: Path) -> str:
return str(p)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("to_str") || result.contains("to_string"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_parts() {
let python = r#"
from pathlib import Path
def get_parts(p: Path) -> tuple:
return p.parts
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("components") || result.contains("parts"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_drive() {
let python = r#"
from pathlib import Path
def get_drive(p: Path) -> str:
return p.drive
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("prefix") || result.contains("drive"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_root() {
let python = r#"
from pathlib import Path
def get_root(p: Path) -> str:
return p.root
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("root") || result.contains("prefix"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-PATHLIB: Implementation in progress"]
fn test_path_anchor() {
let python = r#"
from pathlib import Path
def get_anchor(p: Path) -> str:
return p.anchor
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("prefix") || result.contains("anchor"));
}