|
5 | 5 |
|
6 | 6 | from qtpy import QtWidgets |
7 | 7 |
|
8 | | -from ...utilities import find_display_in_path, is_pydm_app, is_qt_designer, log_failures, path_info, which |
| 8 | +from ...utilities import find_display_in_path, find_file, is_pydm_app, is_qt_designer, log_failures, path_info, which |
9 | 9 |
|
10 | 10 | logger = logging.getLogger(__name__) |
11 | 11 |
|
@@ -51,6 +51,27 @@ def test_find_display_in_path(): |
51 | 51 | assert disp_path == expected |
52 | 52 |
|
53 | 53 |
|
| 54 | +def test_find_file(): |
| 55 | + parent_lvl1 = tempfile.mkdtemp() |
| 56 | + parent_lvl2 = tempfile.mkdtemp(dir=parent_lvl1) |
| 57 | + temp, file_path = tempfile.mkstemp(suffix=".ui", prefix="display_", dir=parent_lvl2) |
| 58 | + direc, fname, _ = path_info(file_path) |
| 59 | + # Try to find the file as is... it should not find it. |
| 60 | + assert find_file(fname) is None |
| 61 | + |
| 62 | + # Try to find the file under base_path |
| 63 | + disp_path = find_file(fname, base_path=direc) |
| 64 | + assert disp_path == file_path |
| 65 | + |
| 66 | + # Try to find the file under the parent folder without recursion (fail) |
| 67 | + disp_path = find_file(fname, base_path=parent_lvl1) |
| 68 | + assert disp_path == None |
| 69 | + |
| 70 | + # Try to find the file under the parent folder with recursion (succeed) |
| 71 | + disp_path = find_file(fname, base_path=parent_lvl1, subdir_scan_enabled=True) |
| 72 | + assert disp_path == file_path |
| 73 | + |
| 74 | + |
54 | 75 | def test_which(): |
55 | 76 | if platform.system() == "Windows": |
56 | 77 | out = which("ping") |
|
0 commit comments