nose

Nosetest including unwanted parent directories

半世苍凉 提交于 2019-12-19 15:44:11
问题 I'm trying to limit nosetests to a specific directory, however during the test run it's including the parent directories of the dir I'm targetting and in doing so throws errors. Here's the key elements of output from the test run: nose.importer: DEBUG: Add path /projects/myproject/myproject/specs nose.importer: DEBUG: Add path /projects/myproject/myproject nose.importer: DEBUG: Add path /projects/myproject nose.importer: DEBUG: insert /projects/myproject into sys.path I'm using buildout with

Nosetest including unwanted parent directories

余生颓废 提交于 2019-12-19 15:44:11
问题 I'm trying to limit nosetests to a specific directory, however during the test run it's including the parent directories of the dir I'm targetting and in doing so throws errors. Here's the key elements of output from the test run: nose.importer: DEBUG: Add path /projects/myproject/myproject/specs nose.importer: DEBUG: Add path /projects/myproject/myproject nose.importer: DEBUG: Add path /projects/myproject nose.importer: DEBUG: insert /projects/myproject into sys.path I'm using buildout with

Installing hstore extension in django nose tests

浪尽此生 提交于 2019-12-18 15:55:25
问题 I've installed the hstore extension successfully, and everything works when I syncdb . (I'm using djorm-ext-hstore) However, nose creates a new temp database to run tests in, and hstore is not installed in it. I need to run CREATE EXTENSION HSTORE; on the test db right before nose syncs the db, but I can't find any info on how to do that. Any ideas? 回答1: This is a non-issue: The best way to fix this is to apply the hstore extension on the default database, template1 psql -d template1 -c

List all Tests Found by Nosetest

你。 提交于 2019-12-18 13:53:12
问题 I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that? 回答1: Version 0.11.1 is currently available. You can get a list of tests without running them as follows: nosetests -v --collect-only 回答2: I recommend using: nosetests -vv --collect-only While the -vv option is not described in man nosetests , "An Extended Introduction to the nose Unit Testing Framework" states that: Using the -vv

How should I verify a log message when testing Python code under nose?

时光毁灭记忆、已成空白 提交于 2019-12-18 10:32:16
问题 I'm trying to write a simple unit test that will verify that, under a certain condition, a class in my application will log an error via the standard logging API. I can't work out what the cleanest way to test this situation is. I know that nose already captures logging output through it's logging plugin, but this seems to be intended as a reporting and debugging aid for failed tests. The two ways to do this I can see are: Mock out the logging module, either in a piecemeal way (mymodule

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

Running specs by tag

时间秒杀一切 提交于 2019-12-18 07:04:07
问题 In Python and nosetests testing framework there is this idea of tagging your tests: from nose.plugins.attrib import attr @attr(speed='slow') def test_big_download(): ... and running the tests that have only specific tags: nosetests -a speed=slow This is very helpful when there is a need to run tests from a specific category or type. Is there anything similar in protractor + jasmine ? The closest functionality I've found is the 'grep' option introduced in 1.6.0 : protractor conf.js --grep=

Passing options to nose in a Python test script

让人想犯罪 __ 提交于 2019-12-18 03:25:02
问题 Rather than running my nose tests from the command line, I'm using a test runner that sets up a few things for all the tests, including a connection to a local test instance of MongoDB. The documentation for nose only seems to indicate how to pass options through the command line or a configuration file located in your home directory. Is there a way to pass options, such as --with-xunit when using a script to run your tests? 回答1: Like this: import nose argv = ['fake', '--with-xunit'] nose

Passing options to nose in a Python test script

非 Y 不嫁゛ 提交于 2019-12-18 03:24:06
问题 Rather than running my nose tests from the command line, I'm using a test runner that sets up a few things for all the tests, including a connection to a local test instance of MongoDB. The documentation for nose only seems to indicate how to pass options through the command line or a configuration file located in your home directory. Is there a way to pass options, such as --with-xunit when using a script to run your tests? 回答1: Like this: import nose argv = ['fake', '--with-xunit'] nose

I need a sample of python unit testing sqlalchemy model with nose

自古美人都是妖i 提交于 2019-12-17 22:10:15
问题 Can someone show me how to write unit tests for sqlalchemy model I created using nose. I just need one simple example. Thanks. 回答1: You can simply create an in-memory SQLite database and bind your session to that. Example: from db import session # probably a contextbound sessionmaker from db import model from sqlalchemy import create_engine def setup(): engine = create_engine('sqlite:///:memory:') session.configure(bind=engine) # You probably need to create some tables and # load some test