MCPcopy Index your code
hub / github.com/github/gh-aw / TestSanitizePythonVariableName

Function TestSanitizePythonVariableName

pkg/stringutil/sanitize_test.go:416–490  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

414}
415
416func TestSanitizePythonVariableName(t *testing.T) {
417 tests := []struct {
418 name string
419 input string
420 expected string
421 }{
422 {
423 name: "dash-separated",
424 input: "my-param",
425 expected: "my_param",
426 },
427 {
428 name: "dot-separated",
429 input: "my.param",
430 expected: "my_param",
431 },
432 {
433 name: "starts with number",
434 input: "123param",
435 expected: "_123param",
436 },
437 {
438 name: "already valid",
439 input: "valid_name",
440 expected: "valid_name",
441 },
442 {
443 name: "with dollar sign (invalid in Python)",
444 input: "$special",
445 expected: "_special",
446 },
447 {
448 name: "mixed special chars",
449 input: "param-name.test",
450 expected: "param_name_test",
451 },
452 {
453 name: "spaces",
454 input: "my param",
455 expected: "my_param",
456 },
457 {
458 name: "empty string",
459 input: "",
460 expected: "",
461 },
462 {
463 name: "only special chars",
464 input: "---",
465 expected: "___",
466 },
467 {
468 name: "number with underscore",
469 input: "123_param",
470 expected: "_123_param",
471 },
472 {
473 name: "camelCase preserved",

Callers

nothing calls this directly

Calls 3

assertSanitizeResultFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected