Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Python Unit Test Case Sample
""" Python Unit Test Case Sample Author: Jayesh Chandrapal """ import unittest class Sort: def sort(self, nums): nums = sorted(nums) # nums.append(1) return nums class Test(unittest.TestCase): def setUp(self): self.app = Sort() def tearDown(self): self.app = None def test1(self): self.assertEqual(self.app.sort([1, 4, 3, 2]), [1, 2, 3, 4], "Should sort input array") def test2(self): self.assertEqual(self.app.sort([4, 3, 2, 1]), [1, 2, 3, 4], "Should work for reverse sorted array") def test3(self): self.assertEqual(self.app.sort([1, 2, 3, 4]), [1, 2, 3, 4], "Should work for already sorted array") def test4(self): self.assertEqual(self.app.sort([-4, -2, -3, -1]), [-4, -3, -2, -1], "Should work for negative elements") def test5(self): self.assertEqual(self.app.sort([3, 3, 3, 3]), [3, 3, 3, 3], "Should work for all equal elements") def test6(self): self.assertEqual(self.app.sort([1]), [1], "Should work for single element") if __name__ == "__main__": unittest.main()
run
|
edit
|
history
|
help
0
print("Hello, world!")
Юра и заселение
:progrm end
init constructor
shuru4
Fig
Which Premier League match should I watch?
Tail recursion & Memoisation utilities
Exercise 4 for lesson 2
Homework exercise