Skip to content

Provide a write_file() method for ChildPath #34

Closed
@vincentdephily

Description

@vincentdephily

What this would bring over using the existing copy_from() for a single file is the ability to copy the file to a different name. Basically I'd like the semantics of write_binary() and write_str() but using an existing file as source.

use assert_fs::prelude::*;

let temp = assert_fs::TempDir::new().unwrap();
temp
   .child("input.txt")
   .write_file("unittest.42.txt")
   .unwrap();
temp.close().unwrap();

The rationale is that my program uses fixed names for various input files (and/or I don't want to bother configuring my program to use other filenames), but I have many different input files for as many different unittests. I want to say "for this test, the content of input.txt will be taken from that example file".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions