import unittest
import os
if __name__ == '__main__':
base_dir = os.path.dirname(os.path.abspath(__file__))
# 写法一:
suite = unittest.TestLoader().discover(
start_dir=os.path.join(base_dir, "scripts", "login", "son"),
pattern="test_*.py",
top_level_dir=os.path.join(base_dir, "scripts", "login"),
)
# 写法二:
suite1 = unittest.defaultTestLoader.discover(
start_dir=os.path.join(base_dir, "scripts", "login"),
pattern="test_*.py",
top_level_dir=os.path.join(base_dir, "scripts")
)
unittest.TextTestRunner(verbosity=2).run(suite1)