Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Lua translation
Well no, and please notice how I said that noisy tests are an issue. It's just that I know why they are how they are (not everyone knows of, or likes, log tabs and other ways of handling bulky outputs). And when I see that a remark on a non-obvious thing does not land, I think there is no use to play back-and-forths and it will be easier just to fix things myself.
So it's good enough when everyone other than us does it? Gotcha lmao.
Oh gosh, if the next thing we are going to have now is reopening and closing the same issue over and over, then please don't, and I will think of something myself.
The kata is much better than it was before the overhaul, so even with the issue of noisy tests, it's at least not as broken as it used to be.
Not an issue.
Python tests print to console.
Kata like this one will always be problematic, because there is no good way to present large amount of potentially large strings full of unprintable characters. Python framework does indeed make many things difficult which other frameworks make easy. But in case of this particular test suite, there are many separate issues:
We have patterns to address each of these, they give relatively nice output, but at the same time they require you to squint your eyes a bit when looking at them as "normal" patterns used for "normal" tests:
pass_on success, orfailon failure. We show small values with assertion messages, and large, bulky values with CW's log tabs.allow_raiseand patch around the thrown exception to prevent ugly stack traces.Exact solution might depend on how much effort we want to put into a single kata. What I would try would be something along the lines of:
... or something along the lines, you get the idea :) With a lot of additional caveats because you most probably want to handle mutation of input arrays, and encode/decode roundtrips, and all of this. So yeah, there is going to be some effort in just making tests look good.
Python tests do not run async, so that's a non-issue. I picked prints because they only show up when you actually expand the test in the UI and so don't need to clutter the whole output with too much detail. More importantly, the Python test framework has many issues, one of which is that it doesn't have more decent logging support and the assertion messages suck, so we prints are actually the better choice here. The test data itself is no more meaningful than the current numbering, so I don't see any reason to change that either.
I'm also sticking to both refsols. Sure, we can roundtrip the random data through the encoder and so have both ends of the data, and we could cop out and use
base64, but why then encourage everyone to not use the stdlib and not give a decent example of what a solution could look like once you have passed the tests?I've pushed a fix for the random b64 data generator.
You don't print to console. Simple as.
It's literally just not how you're meant to write tests for cw, and produces extremely unintuitive (even sometimes nondeterministic!) results for many test frameworks due to async/parallelised test execution etc. There's a reason why every test framework under the sun comes with its own logging/output setup.
Like just put the test data in an
ittitle if you wanna show it to the user, it's entirely baffling that you generate a completely meaningless title and then print the actually meaningful information in it. Even better, use assertion messages like a civilised person. Why are we even showing the inputs of passed tests at all? It just adds more noise to runner output. The user only needs to care about failed inputs anyway.You don't need both refsols, you only need a refsol in a single direction. Generate en/decoded data (whichever is more convenient) and have a refsol that turns it into the other one. On the subject, I'd also advise just importing
base64and using that rather than rolling your own non-standard b64 implementation for the tests.Whilst technically non-problematic, this is still definitely a mistake:
thanks for your kind assessment!
Yup, I see where I forgot a
"".join()on the random base64 generator, will fix that tomorrow.However, you'll have to explain why printing to the console is a bad idea and what else is such a mess here.
@mjpieters you broke it: https://www.codewars.com/kata/5270f22f862516c686000161/discuss/python#68b77e9435ab7f723e334e12
Python:
Only where I wasn't yet familiar with the specific language :-) Swift especially took a while to hit upon a suitable idiom.
C translation (author gone)
Loading more items...