3 ms·
One of the examples they provide on copilot.github.com shows a unit test for strip_suffix function. It does not test for a file name without a suffix, which the
by a-r-t 5y ago
One of the examples they provide on copilot.github.com shows a unit test for strip_suffix function. It does not test for a file name without a suffix, which the function would fail (it removes the last character instead):
def strip_suffix(filename):
"""
Removes the suffix from a filename
"""
return filename[:filename.rfind('.')]
import unittest
def test_strip_suffix():
"""
Tests for the strip_suffix function
"""
assert strip_suffix('notes.txt') == 'notes'
assert strip_suffix('notes.txt.gz') == 'notes.txt'
- zild3d 5y agoGreat, you got 2 assertions for free, which lowers some friction of writing tests. You should still be thinking and be "the pilot". When you start writing additional test cases, it will help you out with those too
- Fragoel2 5y agoHaving to read, understand and spot errors in auto-generated code is not free.
- astrobe_ 5y agoOne should keep in mind that it is just "copy-paste" on steroids (ok, maybe a gallon of steroids), but users should be cautious about the false sense of irresponsibility. Because just like when they copy-paste the top answer on SO, at the end of the day they are responsible for the code they ship.