nosetests

Read nose tests arguments in a file especially @attr

ⅰ亾dé卋堺 提交于 2019-12-18 07:08:35
问题 If I invoke a test script say nosetests -a tag1='one' is there a way to print the user input of tag1 in my script? @attr(tag1=['one', 'two', 'three', 'four']) def test_real_logic(self): #how to print the user input here 回答1: Not without some pain. self.test_real_logic.tag1 should give you all the attributes attached to the function. They are stored as a dictionary within __dict__ attribute of the test function. For test_real_logic.tag1 it would be ['one', 'two', 'three', 'four']. If you do

How to run a single test or single TestCase with django-nose?

社会主义新天地 提交于 2019-12-18 04:28:07
问题 With Django's normal test runner, you can drill down to run tests in a specific app, a specific subclass of TestCase, or a specific test within a specific subclass of TestCase. E.g.: ./manage.py test myapp.MyTestCase.test_something However, django-nose doesn't appear to support anything beyond testing a specific app. How do I replicate the last two behaviors? 回答1: Nose supports the following syntax (note : between test script name and test class name): ./manage.py test myapp.tests.test_script

How do I capture a screenshot if my nosetests fail?

荒凉一梦 提交于 2019-12-18 03:41:16
问题 I am running selenium webdriver tests with nosetests. I want to capture a screenshot whenever nosetests fail. How can I do it in the most effective way, either by using webdriver, python or nosetests features? 回答1: My solution import sys, unittest from datetime import datetime class TestCase(unittest.TestCase): def setUp(self): some_code def test_case(self): blah-blah-blah def tearDown(self): if sys.exc_info()[0]: # Returns the info of exception being handled fail_url = self.driver.current

How do I capture a screenshot if my nosetests fail?

南笙酒味 提交于 2019-12-18 03:41:15
问题 I am running selenium webdriver tests with nosetests. I want to capture a screenshot whenever nosetests fail. How can I do it in the most effective way, either by using webdriver, python or nosetests features? 回答1: My solution import sys, unittest from datetime import datetime class TestCase(unittest.TestCase): def setUp(self): some_code def test_case(self): blah-blah-blah def tearDown(self): if sys.exc_info()[0]: # Returns the info of exception being handled fail_url = self.driver.current

Nosetests Import Error

早过忘川 提交于 2019-12-14 03:56:56
问题 I'm trying to use nosetests to run my tests in a directory structure like this src - file1.py - ... test - helper.py - test_file1.py As you can see, test_file1.py has some functions that test file1.py, so it imports file1.py like this: # In file1.py import file1 import helper # Tests go here... I also use a helper.py file that has some neat functionality built in so that I can create tests more easily. This functionality is achieved by extending a couple of classes in my actual code and

A test running with nosetests fails with ImportError, but works with python command

浪尽此生 提交于 2019-12-14 02:35:12
问题 When run a test with python mycore/tests4extractor.py it works. If run the test with nosetests ./mycore/tests4extractor.py it fails with ImportError: No module named extractor . I am in the helpers folder. The project structure is: helpers/ mycore/ __init__.py extractor.py tests4extractor.py Setting PYTHONPATH to the absolute path to helpers and/or helpers/mycore doesn't help. Answer tests4extractor.py: import mycore from extractor import extract should be changed to: import mycore from

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

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

Is there a gui for nosetests

谁都会走 提交于 2019-12-12 10:49:19
问题 I've been using nosetests for the last few months to run my Python unit tests. It definitely does the job but it is not great for giving a visual view of what tests are working or breaking. I've used several other GUI based unit test frameworks that provide a visual snap shot of the state of your unit tests as well as providing drill down features to get to detailed error messages. Nosetests dumps most of its information to the console leaving it the developer to sift through the detail. Any

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