Skip to content

test tool should support test-only dependencies #1901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
johngmyers opened this issue Mar 30, 2025 · 0 comments
Open

test tool should support test-only dependencies #1901

johngmyers opened this issue Mar 30, 2025 · 0 comments

Comments

@johngmyers
Copy link
Contributor

Feature Request

Is your feature request related to a problem? Please describe:

I want unit tests to use KCL modules that the module under test does not use. I do not want the module under test to require said dependency only because it is used in unit tests.

As an example: the existing unit test framework is very poor at providing information needed for a developer to diagnose why an assertion fails. The minimum expectation of a reasonable assertion would be to print the value of the "actual" upon failure. Better would be to print a diff between the "actual" and "expected" for assertions that have both.

The difflib module is the start of something that could be built into an assertions module, but the issue is how to get tests to depend on an assertions module without having the module under test depend on that same module.

Describe the feature you'd like:

Probably a [test_dependences] section in kcl.mod. This would be used by the kcl test command. It would probably also be updated by the kcl mod update command.

Possibly add a --test flag to kcl mod add.

Describe alternatives you've considered:

Users could make the package under test add the dependency. This is usually undesirable.

The language could create new variants of the assert command which do the comparisons and emit the output. But this would not allow the set of comparisons to be reasonably extended.

Print-a-diff could be put into the core language.

Teachability, Documentation, Adoption, Migration Strategy:

testing.assert_equal(actual, expected) would print a diff from expected to actual if the two values are not equal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant