Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 PyUnit 为我的代码编写单元测试。每次运行任何测试之前都会调用 setup 方法。有没有办法我可以定义一个在开始运行任何测试之前只运行一次的方法?
请帮忙谢谢
您可以在 Python 2.7 和 3.2 中使用setUpClass 或 setUpModule 。
使用测试类的构造函数怎么样?