Add support for nox dirs
We use nox in a lot of places now. We should support that. Change-Id: I21a592b4cea3e4acc7540f00504322c7e6a6edb8
This commit is contained in:
parent
3df738d481
commit
f9bc46226c
@ -5,14 +5,14 @@ ttrun
|
|||||||
Simple CLI to run testtools tests
|
Simple CLI to run testtools tests
|
||||||
|
|
||||||
In a `testrepository` based workflow, sometimes you want/need to run individual
|
In a `testrepository` based workflow, sometimes you want/need to run individual
|
||||||
tests. Additionally, someitmes you want to use a pre-existing tox virtualenv
|
tests. Additionally, someitmes you want to use a pre-existing tox or nox virtualenv
|
||||||
to do so. Or, at least, I do.
|
to do so. Or, at least, I do.
|
||||||
|
|
||||||
Typing
|
Typing
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
.tox/py27/bin/python -m testtools.run some.test
|
.nox/py27/bin/python -m testtools.run some.test
|
||||||
|
|
||||||
Got boring. So this is a simple wrapper.
|
Got boring. So this is a simple wrapper.
|
||||||
|
|
||||||
@ -24,12 +24,12 @@ It has two modes.
|
|||||||
|
|
||||||
Will run that test with the system python.
|
Will run that test with the system python.
|
||||||
|
|
||||||
If you want to re-use a tox virtualenv.
|
If you want to re-use a nox virtualenv.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
ttrun -epy27 some.test
|
ttrun -epy27 some.test
|
||||||
|
|
||||||
Will run some.test in the given tox venv.
|
Will run some.test in the given nox venv.
|
||||||
|
|
||||||
Both modes can be run with no parameters to have testtools run all the tests.
|
Both modes can be run with no parameters to have testtools run all the tests.
|
||||||
|
15
ttrun/cmd.py
15
ttrun/cmd.py
@ -16,6 +16,7 @@
|
|||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -35,14 +36,14 @@ def main():
|
|||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
if args.environment:
|
if args.environment:
|
||||||
return subprocess.call(
|
python_path = f".nox/{args.environment}/bin/python"
|
||||||
[
|
if not os.path.exists(python_path):
|
||||||
".tox/{environment}/bin/python".format(environment=args.environment),
|
python_path = f".tox/{args.environment}/bin/python"
|
||||||
"-m",
|
if not os.path.exists(python_path):
|
||||||
"testtools.run",
|
raise RuntimeError(
|
||||||
]
|
f"{args.environment} does not exist. Have you created it yet?"
|
||||||
+ args.tests
|
|
||||||
)
|
)
|
||||||
|
return subprocess.call([python_path, "-m", "testtools.run"] + args.tests)
|
||||||
else:
|
else:
|
||||||
return testtools.run.main([sys.argv[0]] + args.tests, sys.stdout)
|
return testtools.run.main([sys.argv[0]] + args.tests, sys.stdout)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user