Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Give your tests a progress bar and smarter tracebacks in 3 lines::
pip install nose-progressive
cd your_project
nosetests --with-progressive
.. image:: https://github.com/erikrose/nose-progressive/raw/master/in_progress.png
nose-progressive is a nose_ plugin which displays progress in a stationary bar, freeing the rest of the screen (as well as the scrollback buffer) for the compact display of test failures, which it formats beautifully and usefully. It displays failures and errors as soon as they occur and avoids scrolling them off the screen in favor of less useful output. It also offers a number of other human-centric features to speed the debugging process.
.. _nose: http://somethingaboutorange.com/mrl/projects/nose/
The governing philosophy of nose-progressive is to get useful information onto the screen as soon as possible and keep it there as long as possible while still indicating progress.
nose-progressive indicates progress in a stationary progress bar at the bottom of the screen. It supports a wide variety of terminal types and reacts to terminal resizing with all the grace it can muster. And unlike with the standard dot-strewing testrunner, you can always see what test is running.
nose, like most testrunners, typically waits until the bitter end to show error and failure tracebacks, which wastes a lot of time in large tests suites that take many minutes to complete. We show tracebacks as soon as they occur so you can start chasing them immediately, and we format them much better:
Judicious use of color and other formatting makes the traceback easy to scan. It's especially easy to slide down the list of function names to keep your place while debugging.
Omitting the Traceback (most recent call last) line and using relative paths (optional), along with many other tweaks, fits much more in limited screen space.
Identifying failed tests in a format that can be fed back to nose makes it easy to re-run them::
FAIL: kitsune.apps.wiki.tests.test_parser:TestWikiVideo.test_video_english
To re-run the above, do this::
nosetests --with-progressive kitsune.apps.wiki.tests.test_parser:TestWikiVideo.test_video_english
The frame of the test itself always comes first; we skip any setup frames
from test harnesses and such. This keeps your concentration where it counts.
Also, like unittest itself, we hide any frames that descend into trivial
comparison helpers like assertEquals()
or assertRaises()
.
(We're actually better at it than unittest. We don't just start hiding frames at the first unittest one after the test; we snip off only the last contiguous run of unittest frames. This lets you wrap your tests in the decorators from the mock library, which masquerades as unittest, and still see your tracebacks.)
Editor shortcuts (see below) let you jump right to any problem line in your editor.
For each frame of a traceback, nose-progressive provides an editor shortcut. This is a combination of a filesystem path and line number in a format understood by vi, emacs, the BBEdit command-line tool, and a number of other editors::
vi +361 apps/notifications/tests.py # test_notification_completeness
Just triple-click (or what have you) to select the line, and copy and paste it onto the command line. You'll land right at the offending line in your editor of choice. As a bonus, the editor shortcut is more compact than the stock traceback formatting.
You can set which editor to use by setting any of these, which nose-progressive checks in order:
--progressive-editor
commandline optionNOSE_PROGRESSIVE_EDITOR
environment variable$EDITOR
environment variablenose-progressive fully supports custom error classes like Skip and Deprecated. We note the tests that raise them in realtime, just like normal errors and failures::
TODO: kitsune.apps.sumo.tests.test_readonly:ReadOnlyModeTest.test_login_error
However, when an error class is not considered a failure, we don't show it
unless the --progressive-advisories
option is used, and, even in that case,
we don't show a traceback (since usually the important bit of information is
that the test was skipped, not the line it was skipped on). This stems from
our philosophy of prioritizing useful information.
Custom error classes are summarized in the counts after the run, along with failures and errors::
4 tests, 1 failure, 1 error, 1 skip in 0.0s ^^^^^^ Bold ^^^^^^
The non-zero counts of error classes that represent failures are bold to draw the eye and to correspond with the bold details up in the scrollback. Just follow the bold, and you'll find your bugs.
nose-progressive can run your Django tests via django-nose_. Just install django-nose, then run your tests like so::
./manage.py test --with-progressive --logging-clear-handlers
.. _django-nose: https://github.com/jbalogh/django-nose
::
pip install nose-progressive
Or, get the bleeding-edge, unreleased version::
pip install -e git://github.com/erikrose/nose-progressive.git#egg=nose-progressive
To upgrade from an older version of nose-progressive, assuming you didn't install it from git::
pip install --upgrade nose-progressive
The simple way::
nosetests --with-progressive
My favorite way, which suppresses any noisy log messages thrown by tests unless they fail::
nosetests --with-progressive --logging-clear-handlers
To use nose-progressive by default
_, add with-progressive=1
to
.noserc
.
.. _use nose-progressive by default
: http://readthedocs.org/docs/nose/en/latest/usage.html#basic-usage
--progressive-editor
The editor to use for the shortcuts in tracebacks. Defaults to the value of
$EDITOR
and then "vi". Equivalent environment variable:
NOSE_PROGRESSIVE_EDITOR
.
--progressive-abs
Display paths in traceback as absolute, rather than relative to the current
working directory. This lets you copy and paste it to a shell in a different
cwd or to another program entirely. Equivalent environment variable:
NOSE_PROGRESSIVE_ABSOLUTE_PATHS
.
--progressive-advisories
Show even non-failure custom errors, like Skip and Deprecated, during test
runs. Equivalent environment variable: NOSE_PROGRESSIVE_ADVISORIES
.
--progressive-with-styling
nose-progressive automatically omits bold and color formatting when its
output is directed to a non- terminal. Specifying
--progressive-with-styling
forces such styling to be output regardless.
Equivalent environment variable: NOSE_PROGRESSIVE_WITH_STYLING
.
--progressive-with-bar
nose-progressive automatically omits the progress bar when its output is
directed to a non-terminal. Specifying --progressive-with-bar
forces the
bar to be output regardless. This option implies
--progressive-with-styling
. Equivalent environment variable:
NOSE_PROGRESSIVE_WITH_BAR
.
Each of these takes an ANSI color expressed as a number from 0 to 15.
--progressive-function-color=<0..15>
Color of function names in tracebacks. Equivalent environment variable:
NOSE_PROGRESSIVE_FUNCTION_COLOR
.
--progressive-dim-color=<0..15>
Color of de-emphasized text (like editor shortcuts) in tracebacks. Equivalent
environment variable: NOSE_PROGRESSIVE_DIM_COLOR
.
--progressive-bar-filled=<0..15>
Color of the progress bar's filled portion. Equivalent environment variable:
NOSE_PROGRESSIVE_BAR_FILLED_COLOR
.
--progressive-bar-empty=<0..15>
Color of the progress bar's empty portion. Equivalent environment variable:
NOSE_PROGRESSIVE_BAR_EMPTY_COLOR
.
If you can't get what you want with the above options—for example, if your
editor needs a different line number syntax—you can replace the entire
template that controls the editor shortcut lines of the traceback. You can even
rig clickable URLs <http://blog.macromates.com/2007/the-textmate-url-scheme/>
_ in most terminals <http://stackoverflow.com/questions/2338765/is-there-a-way-to-make-a-link- clickable-in-the-osx-terminal>
_ that take you straight to the right line in
your editor, without even the bother of copy and paste.
--progressive-editor-shortcut-template='<template>'
<template>
is a format string <http://docs.python.org/2/library/string.html#formatstrings>
_ as accepted by
str.format()
. Equivalent environment variable:
NOSE_PROGRESSIVE_EDITOR_SHORTCUT_TEMPLATE
.
The default template is... ::
' {dim_format}{editor} +{line_number:<{line_number_max_width}} {path}{normal}{function_format}{hash_if_function}{function}{normal}'
Here are the available keys:
===================== ======================================================
dim_format A terminal formatting sequence for de-emphasized text.
Affected by --progressive-dim-color
.
editor Your editor, set through --progressive-editor
and
$EDITOR
function The name of the function referenced by this stack frame
function_format A terminal formatting sequence for the function name.
Affected by --progressive-function-color
.
hash_if_function ' # '
if this frame has a function
with a
name; empty otherwise. Useful for commenting out the
function name at the end of a line.
line_number The line number of the instruction this stack frame references
line_number_max_width The maximum width, in characters, of the line numbers in the traceback currently being formatted. Useful for aligning columns.
normal A terminal escape sequence that turns off all special
formatting. A shortcut for term.normal
.
path The path to the file this stack frame references.
Affected by --progressive-abs
.
term A blessings <http://pypi.python.org/pypi/blessings/>
_
Terminal
object, through which you can access any
terminal capability, even compound ones such as
term.bold_blue_on_bright_red
. This is your escape
hatch to wild and crazy things beyond mere colors.
===================== ======================================================
ipdb
. Consider pdbpp
instead.--logging-clear-handlers
works around this.Having trouble? Pop over to the issue tracker
_.
.. _issue tracker
: https://github.com/erikrose/nose-progressive/issues
Thanks to Kumar McMillan for his nose-nicedots_ plugin, which provided inspiration and starting points for the path formatting. Thanks to my support.mozilla.com teammates for writing so many tests that this became necessary. Thanks to Jeff Balogh for django-nose, without which I would have had little motivation to write this.
.. _nose-nicedots: https://github.com/kumar303/nose-nicedots
Erik Rose, while waiting for tests to complete ;-)
1.5.2
1.5.1
invoke
,
which obscures the terminal size.mock
tool.1.5
--progressive-editor-shortcut-template
option, letting you
completely customize the editor shortcuts. Now we support any text editor
that has a go-to-line option, no matter how it's spelled.1.4.3
1.4.2
1.4.1
1.4
--with-id
and --verbosity=2
or higher. (Jason Ward)1.3
1.2.1
1.2
its own package
_... _its own package
: http://pypi.python.org/pypi/blessings/
1.1.1
1.1
$EDITOR
shell variable.1.0
0.7
bbedit -w
.0.6.1
0.6
capture
plugin
and other plugins that make output.0.5.1
0.5
0.4
0.3.1
0.3
0.2
--no-skips
is passed.0.1.2
long_description
now contains
README.0.1.1
0.1
FAQs
A testrunner with a progress bar and smarter tracebacks
We found that nose-progressive demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.