(test_dir)
| 206 | |
| 207 | |
| 208 | def create_selection_tests(test_dir): |
| 209 | class TestAllScenarios(PyMongoTestCase): |
| 210 | pass |
| 211 | |
| 212 | for dirpath, _, filenames in os.walk(test_dir): |
| 213 | dirname = os.path.split(dirpath) |
| 214 | dirname = os.path.split(dirname[-2])[-1] + "_" + dirname[-1] |
| 215 | |
| 216 | for filename in filenames: |
| 217 | if os.path.splitext(filename)[1] != ".json": |
| 218 | continue |
| 219 | with open(os.path.join(dirpath, filename)) as scenario_stream: |
| 220 | scenario_def = json_util.loads(scenario_stream.read()) |
| 221 | |
| 222 | # Construct test from scenario. |
| 223 | new_test = create_test(scenario_def) |
| 224 | test_name = f"test_{dirname}_{os.path.splitext(filename)[0]}" |
| 225 | |
| 226 | new_test.__name__ = test_name |
| 227 | setattr(TestAllScenarios, new_test.__name__, new_test) |
| 228 | |
| 229 | return TestAllScenarios |
no test coverage detected