Similar to this question, I'd like to have Nose run a test (or all tests) n
times -- but not in parallel.
I have a few hundred tests in a project; some are some simple unit tests. Others are integration tests w/ some degree of concurrency. Frequently when debugging tests I want to "hit" a test harder; a bash loop works, but makes for a lot of cluttered output -- no more nice single "." for each passing test. Having the ability to beat on the selected tests for some number of trials seems like a natural thing to ask Nose to do, but I haven't found it anywhere in the docs.
What's the simplest way to get Nose to do this (other than a bash loop)?
A swab is like a large cotton bud. You will use the same swab for both your throat and your nose. If you cannot swab your throat, you can swab both nostrils instead.
The test did not detect the virus, but doesn't rule out an infection. Some self-tests are designed to be used in a series (also known as serial testing). Consider repeating the test 24 to 48 hours later. Multiple negative tests increases the confidence that you are not infected with the virus that causes COVID-19.
A negative COVID-19 test means the test did not detect the virus, but this doesn't rule out that you could have an infection. If you used an antigen test, see FDA instructions on repeat testing. If you have symptoms: You may have COVID-19, but tested before the virus was detectable, or you may have another illness.
You can write a nose test as a generator, and nose will then run each function yielded:
def check_something(arg):
# some test ...
def test_something():
for arg in some_sequence:
yield (check_something, arg)
Using nose-testconfig, you could make the number of test runs a command line argument:
from testconfig import config
# ...
def test_something():
for n in range(int(config.get("runs", 1))):
yield (check_something, arg)
Which you'd call from the command line with e.g.
$ nosetests --tc=runs:5
... for more than one run.
Alternatively (but also using nose-testconfig), you could write a decorator:
from functools import wraps
from testconfig import config
def multi(fn):
@wraps(fn)
def wrapper():
for n in range(int(config.get("runs", 1))):
fn()
return wrapper
@multi
def test_something():
# some test ...
And then, if you want to divide your tests into different groups, each with their own command line argument for the number of runs:
from functools import wraps
from testconfig import config
def multi(cmd_line_arg):
def wrap(fn):
@wraps(fn)
def wrapper():
for n in range(int(config.get(cmd_line_arg, 1))):
fn()
return wrapper
return wrap
@multi("foo")
def test_something():
# some test ...
@multi("bar")
def test_something_else():
# some test ...
Which you can call like this:
$ nosetests --tc=foo:3 --tc=bar:7
You'll have to write a script to do this, but you can repeat the test names on the commandline X times.
nosetests testname testname testname testname testname testname testname
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With