python - 在python中使用一个testclass函数到另一个testclass
问题描述
我在 django testcases 中有两个测试类。我想在 python 中将一个 testclass 函数用于另一个 testclass。restframework 的 django 测试用例:
class TestExample(APITestCase):
def test_ex(self):
print "test_ex"
class TestSample(APITestCase):
def test_sample(self):
print "test_sample"
如何test_ex function
在test_sample
函数中使用
解决方案
一种方法是继承
class TestExample(APITestCase):
def test_ex(self):
print "test_ex"
class TestSample(TestExample):
def test_sample(self):
print "test_sample"
推荐阅读
- javascript - 滚动后带有angularjs文件操作的Ionic1不起作用
- python - 在列表中,如何将每个字符串(混合特殊字符)分成一个字符?
- c++ - 使用其基类对 std::hash 的部分模板特化散列对象
- unit-testing - Codeception - 测试文件夹的不同路径
- excel - 在特定页面上的 Google Chrome 中使用 VBA 从 Excel 打开 PDF
- python - pysnmp:打印机佳能返回错误“超时前未收到 SNMP 响应”(施乐和惠普都可以)
- php - 自定义帖子类型 - 相关产品
- entity-framework-core - 在 Azure QueueTrigger 函数(多线程)中问题插入/更新 EF Core DbContext
- c++ - C/C++:打印(配置)头文件的内容
- c# - 通过参数上的基类初始化交付类?