[Python] unittest template for python script

import unittest
import subprocess

def execute_command(command):
    """Execute a shell command and return its printed value."""
    return subprocess.run(command, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()

class TestTemplate(unittest.TestCase):
    def test_case1(self):
        result = 1
        expected_result = 1
        self.assertEqual(result, expected_result)

if __name__ == '__main__':
    unittest.main(verbosity=2)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *