hammett
=======
.. image:: https://travis-ci.org/boxed/hammett.svg?branch=master
:target: https://travis-ci.org/boxed/hammett
.. image:: https://codecov.io/gh/boxed/hammett/branch/master/graph/badge.svg
:target: https://codecov.io/gh/boxed/hammett
Hammett is a fast python test runner that aims to be compatible with the parts
of pytest most people use (unless that conflicts with the goal of being fast).
It also adds some features that can dramatically improve your testing experience
if you adapt more fully to hammett.
How much faster is hammett?
---------------------------
This will depend on how fast your test suite is.
Hammett isn't magic, it's just a runner made by someone who cares about
performance a lot. It aims to have minimal startup overhead and minimal
overhead for each test. I have written some benchmarks for measuring this
overhead which you can find at https://github.com/boxed/test-benchmarks (TL;DR
if your test suite is < 1s in pytest you will see VAST improvements, if it's
minutes or hours, not so much).
A real world example is running the test suite of tri.declarative:
- pytest: ~860 ms
- hammett: ~160 ms
Or iommi:
- pytest: ~10 s
- hammett: ~8 s
But even if your test suite is big and slow you can still get some big
improvements out of hammett if you often run just one file or one test:
In iommi, running `-k test_render_attrs_none`
- pytest: ~1.3 s
- hammett: ~0.6 s
All of this is from a full and clean run. Hammett has features to avoid that!
Tests locked to a module
------------------------
In hammett you can optionally name your test files `module__tests.py` (that's
two `_`). This tells hammett that if you change `module` only the tests in
`module__tests.py` needs to be run. You can place those files either in the
tests directory or right next to the module you're testing.
Run just relevant tests
------------------------
Hammett keeps track of what modules and what tests have changed and runs only
the tests it needs to. Assuming you lock your tests to a module like above.
If hammett gets confused you can delete the `.hammett-db` file and it will
start from scratch.
Pytest features that work in hammett
------------------------------------
- `pytest.mark`
- parametrized tests
- fixtures
- `with pytest.raises`
Some plugins work, but you have to specify to load them in setup.cfg:
.. code:: ini
[hammett]
plugins=
pytest_django
Usage
------
First install: :code:`pip install hammett`
Then run hammett: :code:`python -m hammett`
Hopefully it will run your entire test suite!
Hammett works with some pytest plugins, most notably pytest-django, at least
for some projects. You need to specify what plugins hammett loads manually
in setup.cfg though.
Keeping pytest compatibility
----------------------------
If you want to use the hammett specific feature of `module__tests.py`-style
test files, you can still keep compatibility with pytest by specifying the
module of your project and the tests file pattern, like this:
.. code::
testpaths=
tests
my_project
python_files=
*__tests.py
Also keep importing pytest instead of hammett obviously.
License
-------
BSD
Raw data
{
"_id": null,
"home_page": "https://github.com/boxed/hammett",
"name": "hammett",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "hammett",
"author": "Anders Hovm\u00f6ller",
"author_email": "boxed@killingar.net",
"download_url": "https://files.pythonhosted.org/packages/2d/1b/9e6e564edf69f3d1c85fa436026490304a39ff8f444c66dba52b29476c82/hammett-0.10.0.tar.gz",
"platform": null,
"description": "hammett\n=======\n\n.. image:: https://travis-ci.org/boxed/hammett.svg?branch=master\n :target: https://travis-ci.org/boxed/hammett\n\n.. image:: https://codecov.io/gh/boxed/hammett/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/boxed/hammett\n\n\nHammett is a fast python test runner that aims to be compatible with the parts\nof pytest most people use (unless that conflicts with the goal of being fast).\nIt also adds some features that can dramatically improve your testing experience\nif you adapt more fully to hammett.\n\n\nHow much faster is hammett?\n---------------------------\n\nThis will depend on how fast your test suite is.\nHammett isn't magic, it's just a runner made by someone who cares about\nperformance a lot. It aims to have minimal startup overhead and minimal\noverhead for each test. I have written some benchmarks for measuring this\noverhead which you can find at https://github.com/boxed/test-benchmarks (TL;DR\nif your test suite is < 1s in pytest you will see VAST improvements, if it's\nminutes or hours, not so much).\n\nA real world example is running the test suite of tri.declarative:\n\n- pytest: ~860 ms\n- hammett: ~160 ms\n\nOr iommi:\n\n- pytest: ~10 s\n- hammett: ~8 s\n\n\nBut even if your test suite is big and slow you can still get some big\nimprovements out of hammett if you often run just one file or one test:\n\nIn iommi, running `-k test_render_attrs_none`\n\n- pytest: ~1.3 s\n- hammett: ~0.6 s\n\nAll of this is from a full and clean run. Hammett has features to avoid that!\n\n\nTests locked to a module\n------------------------\n\nIn hammett you can optionally name your test files `module__tests.py` (that's\ntwo `_`). This tells hammett that if you change `module` only the tests in\n`module__tests.py` needs to be run. You can place those files either in the\ntests directory or right next to the module you're testing.\n\n\nRun just relevant tests\n------------------------\n\nHammett keeps track of what modules and what tests have changed and runs only\nthe tests it needs to. Assuming you lock your tests to a module like above.\n\nIf hammett gets confused you can delete the `.hammett-db` file and it will\nstart from scratch.\n\n\nPytest features that work in hammett\n------------------------------------\n\n- `pytest.mark`\n- parametrized tests\n- fixtures\n- `with pytest.raises`\n\n\nSome plugins work, but you have to specify to load them in setup.cfg:\n\n.. code:: ini\n\n [hammett]\n plugins=\n pytest_django\n\n\nUsage\n------\n\nFirst install: :code:`pip install hammett`\n\nThen run hammett: :code:`python -m hammett`\n\nHopefully it will run your entire test suite!\n\nHammett works with some pytest plugins, most notably pytest-django, at least\nfor some projects. You need to specify what plugins hammett loads manually\nin setup.cfg though.\n\n\nKeeping pytest compatibility\n----------------------------\n\nIf you want to use the hammett specific feature of `module__tests.py`-style\ntest files, you can still keep compatibility with pytest by specifying the\nmodule of your project and the tests file pattern, like this:\n\n.. code::\n\n testpaths=\n tests\n my_project\n python_files=\n *__tests.py\n\nAlso keep importing pytest instead of hammett obviously.\n\n\nLicense\n-------\n\nBSD\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "hammett is a fast python test runner",
"version": "0.10.0",
"project_urls": {
"Homepage": "https://github.com/boxed/hammett"
},
"split_keywords": [
"hammett"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2d1b9e6e564edf69f3d1c85fa436026490304a39ff8f444c66dba52b29476c82",
"md5": "cac44f9cf2fe9bdca404c2ee6b81b08e",
"sha256": "e825aa7ac3e1b2c743fc69e348d709fd072017c34bf223441c969486192abc08"
},
"downloads": -1,
"filename": "hammett-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "cac44f9cf2fe9bdca404c2ee6b81b08e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23540,
"upload_time": "2024-09-23T10:59:41",
"upload_time_iso_8601": "2024-09-23T10:59:41.881999Z",
"url": "https://files.pythonhosted.org/packages/2d/1b/9e6e564edf69f3d1c85fa436026490304a39ff8f444c66dba52b29476c82/hammett-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-23 10:59:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "boxed",
"github_project": "hammett",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "astunparse",
"specs": []
}
],
"lcname": "hammett"
}