Given a `test_path` relative to the self.test_data_dir directory, return the location to a test file or directory for this path. Copy to a temp test location if `copy` is True. Raise an IOError if `must_exist` is True and the `test_path` does not exists.
(self, test_path, copy=False, debug=False, must_exist=True, relative=False)
| 94 | test_data_dir = None |
| 95 | |
| 96 | def get_test_loc(self, test_path, copy=False, debug=False, must_exist=True, relative=False): |
| 97 | """ |
| 98 | Given a `test_path` relative to the self.test_data_dir directory, return the |
| 99 | location to a test file or directory for this path. Copy to a temp |
| 100 | test location if `copy` is True. |
| 101 | |
| 102 | Raise an IOError if `must_exist` is True and the `test_path` does not |
| 103 | exists. |
| 104 | """ |
| 105 | test_data_dir = self.test_data_dir |
| 106 | if debug: |
| 107 | import inspect |
| 108 | |
| 109 | caller = inspect.stack()[1][3] |
| 110 | print('\nself.get_test_loc,%(caller)s,"%(test_path)s"' % locals()) |
| 111 | |
| 112 | test_loc = get_test_loc( |
| 113 | test_path, |
| 114 | test_data_dir, |
| 115 | debug=debug, |
| 116 | must_exist=must_exist, |
| 117 | ) |
| 118 | if copy: |
| 119 | base_name = path.basename(test_loc) |
| 120 | if filetype.is_file(test_loc): |
| 121 | # target must be an existing dir |
| 122 | target_dir = self.get_temp_dir() |
| 123 | fileutils.copyfile(test_loc, target_dir) |
| 124 | test_loc = path.join(target_dir, base_name) |
| 125 | else: |
| 126 | # target must be a NON existing dir |
| 127 | target_dir = path.join(self.get_temp_dir(), base_name) |
| 128 | fileutils.copytree(test_loc, target_dir) |
| 129 | # cleanup of VCS that could be left over from checkouts |
| 130 | self.remove_vcs(target_dir) |
| 131 | test_loc = target_dir |
| 132 | |
| 133 | if relative: |
| 134 | _, _, rel_test_loc = test_loc.rpartition(os.getcwd()) |
| 135 | return rel_test_loc.strip("/") |
| 136 | |
| 137 | return test_loc |
| 138 | |
| 139 | def get_temp_file(self, extension=None, dir_name="td", file_name="tf"): |
| 140 | """ |
no test coverage detected