(msg, prop, *fps)
| 100 | |
| 101 | |
| 102 | def __assert_decorator(msg, prop, *fps): |
| 103 | def decorator(f): |
| 104 | @wraps(f) |
| 105 | def wrapper(*args, **kwargs): |
| 106 | self = args[0] |
| 107 | # We save up the cwd to chdir to it after the test has run so that the |
| 108 | # the given fps still "work" even if the test changed the cwd. |
| 109 | cwd_before = os.getcwd() |
| 110 | before_list = [prop(*args, **kwargs)(fp) for fp in fps] |
| 111 | f(*args, **kwargs) |
| 112 | os.chdir(cwd_before) |
| 113 | after_list = [prop(*args, **kwargs)(fp) for fp in fps] |
| 114 | for fp, before, after in zip(fps, before_list, after_list): |
| 115 | self.assertEqual( |
| 116 | before, after, |
| 117 | '{0} of file "{1}" changed: from "{2}" to "{3}"'.format( |
| 118 | msg, fp, before, after)) |
| 119 | return wrapper |
| 120 | return decorator |
| 121 | |
| 122 | |
| 123 | # Unit tests for file related operations |
no outgoing calls
no test coverage detected