<div class="__aliyun_email_body_block"><div>Hi all,<br>I use python 2.7.3 on windows7 x64. And here is my package structure:<br><br>project_0001/<br>&nbsp; |___plugin_0001/<br>&nbsp; |&nbsp;&nbsp;&nbsp; |___test/<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___test_0001/<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ __init__.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ test.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___test_0002/<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ __init__.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ test.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___test_0003/<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ __init__.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ test.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ __init__.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; |___ test.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |<br>&nbsp; |&nbsp;&nbsp;&nbsp; |_____ __init__.py<br>&nbsp; |&nbsp;&nbsp;&nbsp; |_____ test.py<br><br>I can run all these test cases by typing the following command:<br>cd \project_0001\plugin_0001\test<br>python -m unittest discover<br><br>Now I'm going to filter out packages test_0002 and test_0003. So I add load_tests(...) in project_0001\plugin_0001\test\__init__.py, like this:<br>def load_tests(loader, standard_tests, pattern):<br>&nbsp;&nbsp;&nbsp; # top level directory cached on loader instance<br>&nbsp;&nbsp;&nbsp; this_dir = os.path.dirname(__file__)<br>&nbsp;&nbsp;&nbsp; package_tests = loader.discover(start_dir=this_dir, pattern='test_0001')<br>&nbsp;&nbsp;&nbsp; standard_tests.addTests(package_tests)<br>&nbsp;&nbsp;&nbsp; return standard_tests<br><br>and run the following command:<br>cd \project_0001\plugin_0001\test<br>python -m unittest discover<br>But test_0002 and test_0003 are not filtered out all.<br><br>Then I copy project_0001\plugin_0001\test\__init__.py to project_0001\plugin_0001\__init__.py, and run the following command:<br>cd \project_0001\plugin_0001\<br>python -m unittest discover<br>But test_0002 and test_0003 are not filtered out all too.<br><br><br>Is there anything wrong in my steps? how to filter out packages test_0002 and test_0003?<br><br>Cheers<br>yao</div></div>