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'
Great, 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
One 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.
Comments (1,272) 260 threads
Show all comments
Showing thread 14 of 260
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.