Nose Focus
This provides a nice little decorator and a nose-tests switch to make nose only run the tests that you are focusing on right now.
Changelog
- 0.2.0
No longer support python2, which also means this module now has no dependencies
code is formatted with black
nose_focus tests are now written using pytest
- 0.1.4
When you focus a class, tests using that class outside that module will also be focused
- before 0.1.4
Changelog not kept
Usage
Just use the focus decorator in your tests:
from nose_focus import focus
@focus
def test_my_amazing_feature():
assert_is_awesome(my_feature)
Or set it on your classes:
from nose_focus import focus
@focus
class MyTests(TestCase):
[...]
Or if you also want to focus on subclasses:
@focus_all
class MyTests(TestCase):
[..]
class OtherTests(MyTests):
# Also part of the test because it's parent class has focus_all
[..]
Or at the module level, set nose_focus to True
nose_focus = True
def test_my_other_amazing_feature():
assert_great_things()
And use the switch when you run your tests:
nosetests --with-focus
And the plugin will skip all the tests that we aren’t focusing on or set to be ignored.
You may also use nose_focus to run all your tests except those that are ignored.
from nose_focus import focus_ignore
@focus_ignore
def test_that_is_ignored():
[..]
def test_that_is_not_ignored():
[..]
And use the --without-ignored to make it run all tests except those that are ignored:
nosetests --without-ignored
Api
- nose_focus.focus(func)
Sets nose_focus to True on func
- nose_focus.focus_all(kls)
Sets nose_focus_all to True on kls. The plugin looks for this attribute in the lineage of base classes for each method when determining to skip them or not.
- nose_focus.focus_ignore(thing)
Sets nose_focus_ignore to True on thing. The plugin will look for this on each method and the lineage of base classes and will ignore the method if it finds it.
- –with-focus nosetests switch
Enables the plugin making it only run those tests that are set to focus and are not set to be ignored
- –without-ignored nosetests switch
Makes the plugin run all tests except those that are set to be ignored
How it works
The plugin uses several want* hooks on a nose plugin to only let through methods that we want to focus on.
A method is focused if it or it’s parent class has nose_focus set to a Truthy value or if any class in the lineage of parent classes has nose_focus_all set to a Truthy value and nothing in the lineage has nose_focus_ignore set to a Truthy value.
Installation
Use pip!:
pip install nose-focus
Or if you’re developing it:
pip install -e .
pip install -e ".[tests]"
Tests
To run the tests in this project, just use the helpful script:
./test.sh
Or run tox:
tox
Metadata
Release files for nose-focus 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nose_focus-0.2.0.tar.gz | 5.0 kB | Without provenance | Details for nose_focus-0.2.0.tar.gz |
Release files / nose_focus-0.2.0.tar.gz
| Download URL | nose_focus-0.2.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
207f5902d66da33f6594bcb38e6b64fc80095f8c97c9a752e12081e2c2eb565e
|
|
BLAKE2b-256 checksum How to use checksums |
7a97adbbdc5395d6943e66f94f478a6bdcdb6eea1a06ce4b2225b47d5253c478
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for nose-focus 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.