---
title: "python unittest加载自己写的测试"
author: "heipark"
date: "2015-12-01T22:23:36Z"
tags: []
categories: ["编程语言"]
slug: "python-unittest"
draft: false
lastmod: "2015-12-01T22:23:36Z"
id: 2260955
url: "https://heipark.iteye.com/blog/2260955"
---

在python unittest库中TestLoader中还有，discover是最简单的方式，另外可以直接使用nose。

 

```
def discover():
    loader = unittest.TestLoader()
    suite1 = loader.discover('/xx/xx/xx') 
    suite2 = loader.discover('/yy/yy/yy') 
    alltests = unittest.TestSuite((suite1, suite2))
    return unittest.TextTestRunner(verbosity=2).run(alltests)
```