|
8 | 8 | import shutil |
9 | 9 | import numpy as np |
10 | 10 | import pytest |
| 11 | +import re |
| 12 | +import os |
11 | 13 |
|
12 | 14 |
|
13 | 15 | ##################### FUNCTIONS USED BY TEST CASES ##################### |
@@ -1121,21 +1123,33 @@ def get_voltage_data(expt): |
1121 | 1123 |
|
1122 | 1124 | # Create RunInfo instance and set scan0 to PropertyScan |
1123 | 1125 | runinfo = ps.RunInfo() |
1124 | | - runinfo.scan0 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 1)}, prop='voltage', dt=0.000000001) |
| 1126 | + runinfo.scan0 = ps.RepeatScan(1, dt=0.0000001) |
1125 | 1127 |
|
1126 | 1128 | # Set RunInfo measure_function (remember, it takes a Experiment object as a parameter and |
1127 | 1129 | # returns an ItemAttribute containing data). |
1128 | 1130 | runinfo.measure_function = get_voltage_data |
1129 | 1131 |
|
1130 | 1132 | # Create a Experiment class with the RunInfo and Devices just created |
1131 | 1133 | expt = ps.Experiment(runinfo, devices, time=True) |
1132 | | - try: |
1133 | | - expt.run() |
1134 | | - expt.run() |
1135 | | - expt.run() |
1136 | | - expt.run() |
1137 | | - expt.run() |
1138 | | - expt.run() |
| 1134 | + |
| 1135 | + long_names = [] |
| 1136 | + |
| 1137 | + while len(long_names) < 3: |
1139 | 1138 | expt.run() |
1140 | | - except Exception: |
1141 | | - assert False, f"Fast experiments did not run properly, possible file name overlap. Exception: {Exception}" |
| 1139 | + if len(long_names) == 0: |
| 1140 | + long_names.append(expt.runinfo.long_name) |
| 1141 | + elif (expt.runinfo.long_name[:15] == long_names[0][:15]): |
| 1142 | + long_names.append(expt.runinfo.long_name) |
| 1143 | + else: |
| 1144 | + long_names = [expt.runinfo.long_name] |
| 1145 | + |
| 1146 | + err_str = f"First long name '{long_names[0]}' does not match expected date/time format." |
| 1147 | + assert re.match(r'^\d{8}T\d{6}$', long_names[0]), err_str |
| 1148 | + err_str = f"-1 long name '{long_names[1]}' does not match expected increment or format." |
| 1149 | + assert long_names[1] == long_names[0] + '-1', err_str |
| 1150 | + err_str = f"-2 long name '{long_names[1]}' does not match expected increment or format." |
| 1151 | + assert long_names[2] == long_names[0] + '-2', err_str |
| 1152 | + |
| 1153 | + for name in long_names: |
| 1154 | + save_path = expt.runinfo.data_path / '{}.hdf5'.format(name) |
| 1155 | + assert os.path.exists(save_path), f"Expected file at path'{save_path}' was not found." |
0 commit comments