MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / create_selection_tests

Function create_selection_tests

test/utils_selection_tests.py:208–229  ·  view source on GitHub ↗
(test_dir)

Source from the content-addressed store, hash-verified

206
207
208def 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

Callers 2

TestAllScenariosClass · 0.90
TestAllScenariosClass · 0.90

Calls 3

create_testFunction · 0.70
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected