nose

How to run multiple python file in a folder one after another [duplicate]

孤街浪徒 提交于 2019-12-06 02:53:42
问题 This question already has answers here : Run all Python files in a directory (2 answers) Closed 3 years ago . I have around 20 python files. Each time I run these files in the terminal this form one after another : python a.py python b.py python c.py python d.py python e.py python f.py python g.py . . . (I have provided general file names here) This process takes lot of time. Is it possible to run these file together one after another through any script..? If possible, then how..? Please

How to use nose coverage with --timid flag

拈花ヽ惹草 提交于 2019-12-06 02:30:39
I'd like to run "nosetests --with-coverage" using Ned Batchelder's coverage module , but passing the coverage module the --timid flag. Is there a way (e.g. setting an environment variable) to make coverage run with --timid? You've got two options: Use a .coveragerc file to provide options to coverage.py Instead of running coverage inside nose, run nose inside coverage: coverage run c:\python25\scripts\nosetests-script.py (sorry for the Windows syntax if you aren't on Windows) 来源: https://stackoverflow.com/questions/2735738/how-to-use-nose-coverage-with-timid-flag

Print a different long description in nose tests along with test name python

蹲街弑〆低调 提交于 2019-12-06 02:29:10
I am using the command: nosetests test.py When this is run only the first line of the description gets printed. I want the whole description along with the test name. How do i do that? test.py file import unittests class TestClass(unittest.TestCase): def test_1(self): """this is a long description // continues on second line which does not get printed """ some code; self.assertTrue(True) def test_2(self): """this is another or different long description // continues on second line which does not get printed """ some code; self.assertTrue(True) if __name__ == '__main__': unittest.main()

nose framework command line regex pattern matching doesnt work(-e,-m ,-i)

烂漫一生 提交于 2019-12-06 00:34:44
问题 The python nosetest framework has some command line options to include, exclude and match regex for tests which can be included/excluded and matched respectively. However they don't seem to be working correctly. [kiran@my_redhat test]$ nosetests -w cases/ -s -v -m='_size' ---------------------------------------------------------------------- Ran 0 tests in 0.001s OK [kiran@my_redhat test]$ grep '_size' cases/test_case_4.py def test_fn_size_sha(self): is there some thing wrong with regex

Check that a function raises a warning with nose tests

为君一笑 提交于 2019-12-06 00:01:55
问题 I'm writing unit tests using nose, and I'd like to check whether a function raises a warning (the function uses warnings.warn ). Is this something that can easily be done? 回答1: def your_code(): # ... warnings.warn("deprecated", DeprecationWarning) # ... def your_test(): with warnings.catch_warnings(record=True) as w: your_code() assert len(w) > 1 Instead of just checking the lenght, you can check it in-depth, of course: assert str(w.args[0]) == "deprecated" In python 2.7 or later, you can do

PyCharm unable to load NoseGAE

≡放荡痞女 提交于 2019-12-05 23:59:17
I've created a nose test config in PyCharm. I have NoseGAE installed in the virtualenv where I'm working. Running tests from the terminal with ./env/bin/nosetests --with-gae src/tests works great. The PyCharm test config, however, yields /Users/bistenes/Code/myproject/env/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/noserunner.py src/tests/ Testing started at 6:31 PM ... /Users/bistenes/Code/myproject/env/lib/python2.7/site-packages/nose/plugins/manager.py:395: RuntimeWarning: Unable to load plugin nosegae = nosegae:NoseGAE: nose>=0.10.1 RuntimeWarning) Config is set to

How do I generate coverage xml report for a single package?

…衆ロ難τιáo~ 提交于 2019-12-05 22:08:04
I'm using nose and coverage to generate coverage reports. I only have one package right now, ae , so I specify to only cover that: nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae And here are the results, which look good: Name Stmts Exec Cover Missing ---------------------------------------------- ae 1 1 100% ae.util 253 224 88% 39, 63-65, 284, 287, 362, 406 ---------------------------------------------- TOTAL 263 234 88% ---------------------------------------------------------------------- Ran 68 tests in 5.292s However when I run coverage xml , coverage pulls in more

Skip a unit test from a Nose2 Plugin

╄→尐↘猪︶ㄣ 提交于 2019-12-05 21:00:23
I'm having trouble actually skipping a unit test from a Nose2 plugin. I am able to mark the test skipped and see the reason in the final result, but the test still runs. This example code should basically skip any test, as long as the plugin is active. from nose2.events import Plugin class SkipAllTests(Plugin): def startTest(self, event): event.result.addSkip(event.test, 'skip it') event.handled = True If I call event.test.skipTest('reason') it actually raises the SkipTest exception like it should, it's just that the exception isn't caught by the test runner, it just raises inside of my

Learn Python the Hard Way Exercise 46: Installing Python packages (pip, nose etc.) on Windows

为君一笑 提交于 2019-12-05 20:27:20
I am learning Python using Zed Shaw's "Learn Python the Hard Way" on Windows using PowerShell. I am in Exercise 46 where you set up a skelton project. I downloaded pip , distribute , nose , and virtualenv and I installed them by typing: python <filename>.py install However, probably because they were not installed where they were supposed to, when I try nosetests I get errors saying "The term 'nosetests' is not recognized as the name of a cmdelt, function, script file, or operable program. Check the spelling of the mae, or if a path was included, verify that the path is correct and try again..

Can I nest TestCases with Nose?

半城伤御伤魂 提交于 2019-12-05 14:38:12
I've become a fan of nested test case contexts in things like RSpec and Jasmine, and I'm wondering if there are any Nose plugins that implement a test finder that allows you to nest classes as context. The resulting tests would look something like the following: from nose.tools import * from mysystem import system_state class TestMySystem (TestCase): def setUp(self): system_state.initialize() class WhenItIsSetTo1 (TestCase): def setUp(self): system_state.set_to(1) def test_system_should_be_1 (self): assert_equal(system_state.value(), 1) class WhenItIsSetTo2 (TestCase): def setUp(self): system