bea2038a4249b73e5fd3de42bc25e39b081f61e7
[librarian.git] / tests / utils.py
1 from os.path import realpath, join, dirname
2 import glob
3 import os
4
5
6 def get_fixture_dir(dir_name):
7     """Returns path to fixtures directory dir_name."""
8     return realpath(join(dirname(__file__), 'files', dir_name))
9
10
11 def get_fixture(dir_name, file_name):
12     """Returns path to fixture file_name in directory dir_name."""
13     return join(get_fixture_dir(dir_name), file_name)
14
15
16 def get_all_fixtures(dir_name, glob_pattern='*'):
17     """Returns list of paths for fixtures in directory dir_name matching the glob_pattern."""
18     return [get_fixture(dir_name, file_name) for file_name in glob.glob(join(get_fixture_dir(dir_name), glob_pattern))]
19
20
21 def remove_output_file(dir_name, file_name):
22     try:
23         os.remove(get_fixture(dir_name, file_name))
24     except:
25         pass