-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add pytest as a testing framework for Python #50
Comments
Codewars can only support one test framework per language at the moment because of how the database is set up. So we won't be able to add another test framework until we do the rewrite which I'm planning to start working on after my vacation. I personally don't like having to maintain custom frameworks when there're existing ones we can use (e.g., JS/Python/Ruby, etc.), so I'd like to deprecate them in the future for new contents. We still need to keep them for a while for existing contents though. For Python, I like |
@kazk: Thanks for quick reply. I'll wait patiently. :) Also, I completely agree with your stance on custom frameworks. Enjoy your vacation and good luck with the rewrite. |
@kazk: I came back to this after some time. I guess there's been no progress on this and the single test framework per language limitation is still there. One possible option would be to emulate the existing framework with pytest (i.e. the current framework would be an alternative syntax for pytest. Is this a sensible idea according to you? |
No progress on Codewars part. Have you looked into if
I'll consider it if it's fully backwards compatible and also depending on the amount of effort required. |
@suic86 : but what is the feeback for the user in case a test fails? Seems to me you're comparing |
@Blind4Basics Similar to power asserts from Groovy. So
Fails with something like
It can produce more useful output depending on the test case. |
For reporting I haven't looked into if we can simulate Codewars test framework with |
Feature
pytest test framework support for Python 2 and 3.
Rationale
Issues with the current framework(s)
The currently available test frameworks involve a lot of boilerplate. This is true first and foremost about the most widely used
test.assert_equals
.The code using this test framework has very high noise to signal ratio and it's hard to parse visually as
test.assert_equals
isn't syntax-highlighted and there's no significantly visible separation (it's a single comma) between actual and expected value.* Also, this framework is custom and can't be used outside of CW.I'll use the following example (taken from this discussion) in which 37.5% is boilerplate, to support my point
A comparison with the same tests written in Groovy using junit demonstrate how cluttered this Python code is. The two main differences I want to point out:
assert
is highlighted and there's a highlighted separation (==
) between actual and expected values (the highlighting on CW is even better in this respect).Proposed Solution: pytest
pytest test framework offers user experience similar to Groovy with little clutter and detailed info about the failing tests. As a demonstration: The Groovy code above can be used in pytest with minimal changes and the code (as it is) can be used outside CW too.
Notes
* IMHO the use of this framework can be by no means to be considered as best practice.
The text was updated successfully, but these errors were encountered: