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