Ward is a modern test framework for Python with a focus on productivity and readability.
MIT License
Bot releases are visible (Hide)
Published by darrenburns over 3 years ago
Adds when
param to @skip
and @xfail
decorators, allowing you to only apply them when some boolean or Callable predicate holds. e.g.
@skip("Skipped on Windows", when=platform.system() == "Windows")
@test("_build_package_name constructs package name '{pkg}' from '{path}'")
def _(
pkg=each("", "foo", "foo.bar"),
path=each("foo.py", "foo/bar.py", "foo/bar/baz.py"),
):
m = ModuleType(name="")
m.__file__ = path
assert _build_package_name(m) == pkg
@skip("Skipped on Unix", when=platform.system() != "Windows")
@test("_build_package_name constructs package name '{pkg}' from '{path}'")
def _(
pkg=each("", "foo", "foo.bar"),
path=each("foo.py", "foo\\bar.py", "foo\\bar\\baz.py"),
):
m = ModuleType(name="")
m.__file__ = path
assert _build_package_name(m) == pkg
When run on a non-Windows system:
Published by darrenburns over 3 years ago
Relative imports are now supported in test modules and dependencies.
Published by darrenburns over 3 years ago
Test modules will now be added to sys.modules
.
Published by darrenburns over 3 years ago
Ward will automatically stop capturing output when a debugging session is started via pdb.set_trace()
or breakpoint()
.
Published by darrenburns over 3 years ago
Fixes a minor display issue where an extra line of space was being displayed above the code snippet output when an assertion failed.
Published by darrenburns over 3 years ago
Bugfix means that using lambdas inside each
works as you would expect.
Thanks to @JoshKarpel for contributing this fix!
Published by darrenburns over 3 years ago
ward fixtures
allows you to find test fixture dependencies and unused fixtures in your project by printing out
The ward fixtures --show-dependency-trees
command now uses the Tree
class from Rich to construct it's output:
The standard ward fixtures
command which simply lists all fixtures that Ward is able to find in a project now also uses Rich for output:
Contribution by @JoshKarpel
Rich: https://github.com/willmcgugan/rich/
Published by darrenburns over 3 years ago
Running ward completions
will install a tab completion script for your terminal.
Published by darrenburns over 3 years ago
Migrates all output associated with ward test
to the Rich library for terminal output.
Published by darrenburns over 4 years ago
Refactor and improvements to ward fixtures
output, which allows you to view information about fixtures in your project and the tests that use them. Thanks @JoshKarpel!
Published by darrenburns over 4 years ago
toml
to 0.10.0 #164Thanks @hoefling and @JoshKarpel!
Published by darrenburns over 4 years ago
If tests are incorrectly parameterised (e.g. mismatch in each
argument counts), they will now fail without running and won't be expanded into parameterised instances.
Published by darrenburns over 4 years ago
The --show-diff-symbols
option has been added, which allows you to present diffs using symbols rather than background colours. This improves accessibility and support for CI systems that don't support ANSI terminal output.
Published by darrenburns over 4 years ago
Workaround for a bug in virtualenv which means site.getsitepackages() is not available inside virtual envs. https://github.com/pypa/virtualenv/issues/228
Published by darrenburns over 4 years ago
Ward will no longer look in site-packages when discovering tests, preventing interference from third party packages that don't exclude tests from their distributions.
Thanks to @anlutro for this!
Published by darrenburns over 4 years ago
Adds the fixtures
subcommand. By default this command lists out all fixtures present in the project. For example, running ward fixtures
gives us the following output:
We can also run ward fixtures --show-dependency-tree
to see the relationship between fixtures:
Thanks to @JoshKarpel for this contribution!
Published by darrenburns over 4 years ago
You can now tag tests using the tags
keyword argument of the @test
decorator:
@test("simple addition", tags=["unit", "regression"])
def _():
assert 1 + 2 == 3
To query these tags, you can use a tag expression.
ward --tags EXPR
More examples of tag expressions:
Tag Expression | Meaning |
---|---|
slow |
tests tagged with slow |
unit and integration |
tests tagged with both unit and integration
|
big and not slow |
tests tagged with big that aren't also tagged with slow
|
android or ios |
tests tagged with either android or ios
|
You can use parentheses in tag expressions to change precedence rules to suit your needs.
Thanks @thebigmunch for adding this feature.
Published by darrenburns over 4 years ago
Published by darrenburns over 4 years ago
A release earlier today (11 March 2020) introduced an issue where Ward would raise an exception when a non-comparison based assertion failed. This release fixes that issue.
Published by darrenburns over 4 years ago
User is informed if Ward finds and uses their pyproject.toml. Thanks to @mandarvaze.