相关疑难解决方法(0)

使用Nose在目录中运行所有测试

我需要能够通过在Linux shell中键入一行来在当前目录中运行所有测试.在某些目录中,这很好用.但在其他情况下,当我输入"nosetests"时,没有进行任何测试.如果我单独调用它们,测试将运行,但我需要它们全部自动运行.这是一个不起作用的目录:

/extwebserver
    __init__.py
    test_Detection.py
    test_Filesystem.py 
    test_Hardware.py
    ...
Run Code Online (Sandbox Code Playgroud)

当我在父目录中运行"nosetests"时,将运行某个子目录中的所有测试,但不会运行/ extwebserver或其他子目录或父目录本身的测试.

编辑 这是输出:

matthew@Matthew-Laptop:~/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing$ nosetests -vv --collect-only
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/baseTestCase.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/run.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Detection.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Filesystem.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Hardware.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Mode.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_System.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_View.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Webserver.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/mocks/bottle.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/utils/test_timestamps.py is …
Run Code Online (Sandbox Code Playgroud)

python nose

23
推荐指数
2
解决办法
2万
查看次数

鼻子没有找到Django测试

我试图使用Django的鼻子在我目前的项目,但我无法弄清楚如何让鼻子跑我的测试.所以我开始了一个简单的Django 1.4.1项目来了解鼻子.但即使在这个简单的测试项目中,我也无法运行它.

在继续之前:我知道Stackoverflow上有很多类似的问题,比如这个问题:

我怎么告诉Django-nose我的测试在哪里?

但谷歌搜索后,阅读博客文章和StackOverflow答案我仍然无法运行.

我如何设置我的测试项目

  1. 创建虚拟环境.
  2. pip install django django-nose nose.
  3. django-admin.py startproject djangonosetest.创建项目.
  4. 创建一个应用程序 manage.py startapp testapp
  5. 编辑settings.py:

    • 设置ENGINEdjango.db.backends.sqlite3
    • 添加django_nose,testappINSTALLED_APPS
    • 补充说TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'.
  6. manage.py test

但我得到的只是这个输出:

nosetests --verbosity 1
Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...
Run Code Online (Sandbox Code Playgroud)

但至少应该运行默认的测试用例.

当我运行python manage.py test djangonosetest.testapp.tests:SimpleTest它时,将运行测试.但是,如果我必须为每个测试文件执行此操作,那似乎有点矫枉过正.但它证明了测试可以运行.

当我跑manage.py test -v 3(高级别级别)时,这出现了:

nose.selector: INFO: /Users/Jens/Projects/Django/djangonosetest/djangonosetest/settings.py …
Run Code Online (Sandbox Code Playgroud)

django nose django-nose

13
推荐指数
1
解决办法
3321
查看次数

有没有办法让python的鼻子模块在__main__和命令行中工作相同?

我不确定如何使鼻子模块的__main__处理程序工作.我在测试模块的末尾有这个:

if __name__ == "__main__":
    import nose
    nose.main()
Run Code Online (Sandbox Code Playgroud)

这给了我:

----------------------------------------------------------------------
Ran 0 tests in 0.002s

OK
Run Code Online (Sandbox Code Playgroud)

但它通过命令行运行相同的东西,它找到测试并执行它们:

MacBook-Pro:Storage_t meloam$nosetests FileManager_t.py 
............E..
======================================================================
ERROR: testStageOutMgrWrapperRealCopy (WMCore_t.Storage_t.FileManager_t.TestFileManager)
----------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

SNIP

----------------------------------------------------------------------
Ran 15 tests in 0.082s

FAILED (errors=1)
Run Code Online (Sandbox Code Playgroud)

我一直在玩通过不同的参数到nose.main()但我找不到任何有用的东西.我错过了一些非常明显的东西吗

谢谢

python nose nosetests

10
推荐指数
3
解决办法
3598
查看次数

标签 统计

nose ×3

python ×2

django ×1

django-nose ×1

nosetests ×1