MCPcopy Index your code
hub / github.com/RustPython/RustPython / create_test_function

Function create_test_function

extra_tests/test_snippets.py:64–76  ·  view source on GitHub ↗

Create a test function for a single snippet

(cls, filename, method, test_type)

Source from the content-addressed store, hash-verified

62
63
64def create_test_function(cls, filename, method, test_type):
65 """Create a test function for a single snippet"""
66 core_test_directory, snippet_filename = os.path.split(filename)
67 test_function_name = "test_{}_".format(method) + os.path.splitext(snippet_filename)[
68 0
69 ].replace(".", "_").replace("-", "_")
70
71 def test_function(self):
72 perform_test(filename, method, test_type)
73
74 if hasattr(cls, test_function_name):
75 raise ValueError("Duplicate test case {}".format(test_function_name))
76 setattr(cls, test_function_name, test_function)
77
78
79def populate(method):

Callers 1

wrapperFunction · 0.85

Calls 6

hasattrFunction · 0.85
setattrFunction · 0.85
splitextMethod · 0.80
splitMethod · 0.45
formatMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected