Crate xvc_test_helper

Crate xvc_test_helper 

Source
Expand description

Helper functions to create random temporary directories, random binary or text files, and set logging in unit/integration tests. The directories may be initialized as Git or Xvc repositories.

Functions§

create_directory_tree
Build a directory tree containing n_dirs under root. Each of these directories contain n_files_per_dir random binary files.
create_temp_dir
Create a random named temp directory under $TMPDIR
generate_filled_file
Creates a file filled with byte
generate_random_file
Generate a random binary file
generate_random_text_file
Generate a random text file composed of alphanumerics
make_symlink
Creates a symlink from target to original
random_dir_name
Generates a random name with prefix and a random number generated from seed. If seed is None, a random number from_entropy is used.
random_temp_dir
Return name of a random directory under $TMPDIR. It doesn’t create the directory, just returns the path.
run_in_temp_dir
Create a temporary dir under $TMPDIR and cd to it
run_in_temp_git_dir
Create an empty temporary Git repository without XVC_DIR
seeded_temp_dir
Return a temp directory created with a seed. If seed is None, it creates a random directory name. This function doesn’t create the directory.
temp_git_dir
Create a random directory and run git init in it.
test_logging
Turn on logging for testing purposes. Testing always send traces to $TMPDIR/xvc.log. The level here determines whether these are sent to stdout.