Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ time = { version = "0.3.37", features = ["local-offset"] }
[dev-dependencies]
insta = { version = "1.41.1", features = ["yaml"] }
tempfile = "3.15.0"
tmp-path = "0.1.0"
12 changes: 6 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ fn print_config_value<T: Display>(label: &str, value: &Option<T>) {
#[cfg(test)]
mod tests {
use super::*;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn mock_config() -> Config {
let mut base = tempdir().unwrap().path().to_path_buf();
base.push("python-project-generator");
let config_dir = base.clone();
tmp_path.push("python-project-generator");
let config_dir = tmp_path.clone();
create_dir_all(&config_dir).unwrap();
base.push("config.json");
let config_file_path = base;
tmp_path.push("config.json");
let config_file_path = tmp_path;

let config = Config {
config_dir: Some(config_dir).into(),
Expand Down
5 changes: 3 additions & 2 deletions src/github_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,9 @@ mod tests {
};
use insta::assert_yaml_snapshot;
use std::fs::create_dir_all;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn project_info_dummy() -> ProjectInfo {
ProjectInfo {
project_name: "My project".to_string(),
Expand Down Expand Up @@ -1581,7 +1582,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
project_root_dir: Some(tmp_path),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/licenses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ mod tests {
use crate::project_info::ProjectManager;
use insta::assert_yaml_snapshot;
use std::fs::create_dir_all;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn project_info_dummy() -> ProjectInfo {
ProjectInfo {
project_name: "My project".to_string(),
Expand Down Expand Up @@ -290,7 +291,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
project_root_dir: Some(tmp_path),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ mod tests {
use super::project_info::{LicenseType, ProjectManager};
use super::*;
use std::fs::create_dir_all;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[test]
#[tmp_path]
fn test_delete_slug() {
let base = tempdir().unwrap().path().to_path_buf();
let project_slug = "test-project";
let slug_dir = base.join(project_slug);
let slug_dir = tmp_path.join(project_slug);
let project_info = ProjectInfo {
project_name: "My project".to_string(),
project_slug: project_slug.to_string(),
Expand Down Expand Up @@ -445,7 +445,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(base),
project_root_dir: Some(tmp_path),
};
create_dir_all(&slug_dir).unwrap();
assert!(slug_dir.exists());
Expand Down
5 changes: 3 additions & 2 deletions src/project_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,9 @@ mod tests {
use super::*;
use crate::project_info::{DocsInfo, LicenseType, ProjectInfo, Pyo3PythonManager};
use insta::assert_yaml_snapshot;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn project_info_dummy() -> ProjectInfo {
ProjectInfo {
project_name: "My project".to_string(),
Expand Down Expand Up @@ -1298,7 +1299,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
project_root_dir: Some(tmp_path),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/python_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ mod tests {
use crate::project_info::{LicenseType, ProjectInfo, ProjectManager, Pyo3PythonManager};
use insta::assert_yaml_snapshot;
use std::fs::create_dir_all;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn project_info_dummy() -> ProjectInfo {
ProjectInfo {
project_name: "My project".to_string(),
Expand Down Expand Up @@ -402,7 +403,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
project_root_dir: Some(tmp_path),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/rust_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ mod tests {
use crate::project_info::{LicenseType, ProjectInfo, ProjectManager, Pyo3PythonManager};
use insta::assert_yaml_snapshot;
use std::fs::create_dir_all;
use tempfile::tempdir;
use tmp_path::tmp_path;

#[tmp_path]
fn project_info_dummy() -> ProjectInfo {
ProjectInfo {
project_name: "My project".to_string(),
Expand Down Expand Up @@ -166,7 +167,7 @@ mod tests {
include_docs: false,
docs_info: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
project_root_dir: Some(tmp_path),
}
}

Expand Down
Loading