nose

How to run python scripts as test suites (running a set of tests together) using nose tests?

我是研究僧i 提交于 2019-12-11 09:39:08
问题 I have a about 50 automated scripts in Python and I would like to separate them as test suites - approx 5 in each meaning 10 suites. How do I achieve it using nosetests? 回答1: How about just using: > nosetests script1.py script2.py script3.py script4.py script5.py > nosetests script3.py script4.py script5.py script6.py script7.py > ... If you organize your suits into folders you can run all tests in a folder in a single run. Alternatively, you can use attrib plugin and mark individual tests as

Why does Nose not see any of my environmental variables?

萝らか妹 提交于 2019-12-11 07:53:02
问题 I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables. So far, the errors: AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE' I fixed this by exporting DJANGO_SETTINGS_MODULE from .bash_profile export DJANGO_SETTINGS_MODULE="settings" Now I'm seeing: AttributeError: 'Settings' object has no attribute 'DATABASE_SUPPORTS_TRANSACTIONS' Why would iPython and the Django webserver be able to see these

python - Nose not discovering package level tests in Django

拟墨画扇 提交于 2019-12-11 01:45:52
问题 I'm setting up a directory structure for my Django app to separate functional and unit tests. I am using nose as the test runner for my Django project. At the root of the Django project, I have a folder called "tests" that has this structure: tests ├── __init__.py ├── functional │ ├── __init__.py └── unit ├── __init__.py ├── data.py ├── tests.py If I want to run just the unit tests, should I not be able to use the following from the project root: $ nosetests tests.unit -----------------------

Nosetest and unittest.expectedFailures

杀马特。学长 韩版系。学妹 提交于 2019-12-10 19:55:23
问题 I am currently testing my website with Selenium, Python and nosetests. Everything works fine for success tests, I got a problem on failure tests (I have never test with Python / Selenium / Nosetest so ...). For the following test : @unittest.expectedFailure def test_connection_failure(self): # Fill the username with the login only self.driver.find_element_by_id('form_identifiant').send_keys(test_login) # Send the form self.driver.find_element_by_id('form_submit').click() # Check the landing

Nose not running Django doctests

随声附和 提交于 2019-12-10 17:37:09
问题 Similar to this question. However, in my case, none of my models' doctest are running. I'm using Django 1.3 beta 1. # settings.py TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' INSTALLED_APPS = ( ##...a bunch of django apps 'django_nose', 'south', 'my_project.my_app', ) One of my model's doctest: class ItemType(models.Model): ''' >>> temType.objects.all().count() == 0 True ''' name = models.CharField(max_length=32) def __unicode__(self): return self.name Should fail because of initial_data

Manually adding test suite to nose

北城以北 提交于 2019-12-10 17:33:04
问题 I want to create a test suite manually instead of using test discovery (only in one module, the others should use discovery). I found how I can do this in unittests, but I'm not sure how to transfer that to nose and how it mixes with the discovery. The nose docs don't have examples and I don't understand how I'm supposed to use them. Could somebody please give me an example? Details: I have test classes where I want to run each method a few times with different parameters. Ideally also

How to get django-nose installed correctly?

亡梦爱人 提交于 2019-12-10 13:13:50
问题 I'm having trouble getting django-nose running. Per the installation instructions, I installed by: Running pip install django-nose Adding 'django_nose' to INSTALLED_APPS in settings.py (including at as the very last app, in case of possible app order issues) Adding TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' to settings.py When I run a test i.e. manage.py test , I get: django.db.utils.DatabaseError: no such table: django_content_type I figured I need to sync the database. I am using South

Python unittest: Retry on failure with Nose?

谁都会走 提交于 2019-12-10 11:27:00
问题 I have a test which randomly fails and I want to let it retry a number of times before sending an error message. I'm using python with Nose. I wrote the following, but unfortunately, even with the try/except handling, Nose returns an error when the test fails on the first try. def test_something(self): maxAttempts = 3 func = self.run_something attempt = 1 while True: if attempt == maxAttempts: yield func break else: try: yield func break except: attempt += 1 def run_something(self): #Do stuff

Running python nose tests in virtual-env

点点圈 提交于 2019-12-10 11:04:53
问题 I have a script go.py , which needs to run unit tests (with nose) on several different modules, each with their own virtual envs. How can I activate each virtual env prior to testing, and deactivate it after? i.e. I want to do this (pseudo-code): for fn in functions_to_test: activate(path_to_env) run_test(fn) deactivate() activate() Inside a virtual env, there is ./bin/activate_this.py This does what I want. So in go.py I say import os activate_this_file = os.path.join(env_dir,'bin/deactivate

Why does nose finds tests in files with only 644 permission?

女生的网名这么多〃 提交于 2019-12-10 03:51:04
问题 Today I ran a bunch of doctests using Python 2.6 on a Ubuntu 9.10 with nose : nosetests --with-doctest Ran 0 tests in 0.001s OK WTF? I had tests in that files, why didn't that work? I changed permission to 644: sudo chmod 644 * -R nosetests --with-doctest Ran 11 test in 0.004s FAILED (errors=1) Changing it back to 777: sudo chmod 777 * -R nosetests --with-doctest Ran 0 tests in 0.001s OK Why is that? Using 644, I can't even edit my files! 回答1: Try the --exe flag: $ nosetests --help ... --exe