예제 #1
0
 def test_that_consecutive_calls_with_same_seed_return_same_files(self, test_corpus_path):
     seed = 13
     num_files = 100
     woodblock.random.seed(seed)
     files = draw_files(test_corpus_path, num_files)
     for _ in range(1000):
         woodblock.random.seed(seed)
         for f1, f2 in zip(files, draw_files(test_corpus_path, num_files)):
             assert _replace_uuid(f1.as_fragment().metadata) == _replace_uuid(f2.as_fragment().metadata)
예제 #2
0
 def test_that_not_enough_unique_files_raise_an_error(self, num_files, test_corpus_path):
     with pytest.raises(WoodblockError):
         print(draw_files(test_corpus_path, num_files, unique=True))
예제 #3
0
 def test_that_files_are_unique_when_desired(self, num_files, test_corpus_path):
     assert len(draw_files(test_corpus_path, num_files, unique=True)) == num_files
예제 #4
0
 def test_that_invalid_paths_raise_an_error(self, path):
     with pytest.raises(WoodblockError):
         draw_files(pathlib.Path(path), number_of_files=1)
예제 #5
0
 def test_that_invalid_number_of_files_raises_an_error(self, num_files, test_data_path):
     with pytest.raises(WoodblockError):
         draw_files(test_data_path, num_files)
예제 #6
0
 def test_that_the_correct_number_of_files_gets_drawn(self, num_files, test_corpus_path):
     assert len(draw_files(test_corpus_path, num_files)) == num_files
예제 #7
0
 def test_that_an_error_is_raised_when_the_path_is_empty(self):
     with TemporaryDirectory() as tmpdir:
         with pytest.raises(WoodblockError):
             draw_files(tmpdir)