import unittest
from paycheck import with_checker
class TestStrings(unittest.TestCase):
@with_checker([int])
def test_sort(self, list_of_ints):
self.assertTrue(isinstance(list_of_ints, list))
self.assertTrue(len(list_of_ints) == len(qsort(list_of_ints)))
self.assertTrue(False)
if __name__ == '__main__':
unittest.main()
def qsort (list):
if list == []:
return []
else:
pivot = list [0]
lesser = qsort([x for x in list[1:] if x<pivot])
greater = qsort([x for x in list[1:] if x>=pivot])
return lesser + [pivot] + greater
这给了我global name qsort not defined
(即使我在同一个班级有它)。这里有什么问题?我想这很简单,但我对 Python 还不是很熟悉。