nose

Run all Tests in Directory Using Nose

五迷三道 提交于 2019-12-17 19:17:39
问题 I need to be able to run all tests in the current directory by typing one line in the Linux shell. In some directories, this works fine. But in others, when I type "nosetests" no tests are run. The tests will run if I call for them individually but I need them to all run automatically. Here is one of the directories that won't work: /extwebserver __init__.py test_Detection.py test_Filesystem.py test_Hardware.py ... When I run "nosetests" in the parent directory, all tests in a certain

Is there a way for a Python Nose test to know its decorated attributes?

你离开我真会死。 提交于 2019-12-13 02:36:47
问题 I have some tests like: @attr('sanity', 'someothertag') def test_this_important_feature(self): """Comment - Verify the very imporant feature I'm wondering if there's a way to see the attributes on the test from inside the test. Alternatively (and probably preferably), is there a way to link the attributes of each test to each test that Nose finds? For the above example, it'd be something like: test_this_important_feature: ('sanity','someothertag') I run all of these tests and capture the

How do I install the pip package for python on mac osx?

拈花ヽ惹草 提交于 2019-12-13 02:11:46
问题 I'm currently stuck on exercise 46 in Zed Shaw's "Learn Python the Hardway". He says I need to install the following python packages: pip distribute nose virtualenv He doesn't give the reader any directions on how to properly install the packages and use them. I went to the pip website but the directions were also very vague and kind of unhelpful for a newbie. The installation guide found on https://pip.pypa.io/en/latest/installing.html says to download the get-pip.py file and then run it by

python nose from a script, gathers test classes from files and then runs tests

╄→尐↘猪︶ㄣ 提交于 2019-12-12 20:09:48
问题 How would I use nose from a python script to gather python files from a directory foreach file run all test classes found using passed parameters Here's an example, given files /run.py /tests/TestClassA.py and within TestClassA.py is the code class A(): __init__(self, b): self._b = b test_run(): print("%s",self._b) To restate the need: I want to call nose from run.py. I want nose (or some part of nose) to find class A in file TestClassA.py create an instance of A , named a , passing the

Python run unittests continuously or each test multiple times

僤鯓⒐⒋嵵緔 提交于 2019-12-12 16:19:10
问题 I have wrote unit test cases to test my application. and it is working as expected with out issues. below is some sample testcase import os import unittest class CreateUser(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_send_message(self): #my script goes here print "success" if __name__ == '__main__': unittest.main() If i run this test it executing as expected but I want to run this test case 'N' no of times , for that i added for loop in main function, also its

Using Nose & NoseXUnit on a Python package

只愿长相守 提交于 2019-12-12 11:25:29
问题 This is a previous post detailing a CI setup for Python. The asker and answerer detail the use of Nose and NoseXUnit with Hudson for their builds. However, NoseXUnit throws an error when run on any source folder where init .py is present: File "build/bdist.linux-x86_64/egg/nosexunit/tools.py", line 59, in packages nosexunit.excepts.ToolError: following folder can not contain __init__.py file: /home/dev/source/web2py/applications I can't think of a source folder of mine that is not a package

Nose tools and pylint

核能气质少年 提交于 2019-12-12 10:54:35
问题 What is the right way to use nose.tools and keep pylint happy? The following code: ''' This is a test ''' import nose.tools import nose.tools.trivial nose.tools.assert_equal(1, 1) nose.tools.assert_equals(1, 1) nose.tools.trivial.assert_equal(1, 1) nose.tools.trivial.assert_equals(1, 1) Results in the following pylint errors: $ pylint -i y -r n /tmp/aseq.py ************* Module aseq E1101: 8,0: Module 'nose.tools' has no 'assert_equal' member E1101: 9,0: Module 'nose.tools' has no 'assert

How to organize and run unittests and functional tests separately using nosetests

不打扰是莪最后的温柔 提交于 2019-12-12 10:36:30
问题 I have the following typical python project file structure packageA +----subpackage1 +----classa.py +----subpackage2 +----classb.py +----test +----subpackage1 +----classa_test.py +----subpackage2 +----classb_test.py I am currently trying to organize my unittests and functional tests so I can run unittests and functional tests separately using nose but also have the option to run all tests. The tests would live in packageA/test/subpackage1 and packageA/test/subpackage2. What is a good way to

Why can't nosetests find one the elements in sys.path?

前提是你 提交于 2019-12-11 12:14:09
问题 I have a series of unit tests that I'm running with nose . For some of my tests, I'd like to remove a module's path from the sys.path so there is no conflict with what I am testing. sys.path.remove('/path/to/remove/from/sys/path') If I run the Python interpreter and call sys.path , the '/path/to/remove/from/sys/path' is there in the list. However, once nosetests is called, the above code cannot find it and gives me a "not found in list" error. Why is nose not able to find the path in sys.path

use class method in nose parameterize.expand call

吃可爱长大的小学妹 提交于 2019-12-11 10:48:17
问题 I have a generator method that is building a large set of test criteria, I know i can make a non class method to be called, but I much rather have the parameter building method be part of my test class. is there a way to do this? here is a simple description of what I want to do: class MyUnitTestClass(TestCase): @staticmethod def generate_scenarios(): yield ('this_is_my_test', 1, 2) @parameterized.expand(generate_scenarios()) def test_scenario(self, test_name, input, expected_output) self