{"id":37081317,"url":"https://github.com/yurifari/django-3t","last_synced_at":"2026-01-14T09:52:39.830Z","repository":{"id":57418694,"uuid":"230299256","full_name":"yurifari/django-3t","owner":"yurifari","description":"Django 3T is a Django Template Testing Tool which aims to help developers to write better tests where the Django template engine is involved.","archived":false,"fork":false,"pushed_at":"2020-02-18T22:56:06.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T10:49:58.563Z","etag":null,"topics":["django","templates","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yurifari.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-26T17:03:50.000Z","updated_at":"2020-01-27T17:21:25.000Z","dependencies_parsed_at":"2022-09-13T13:20:23.986Z","dependency_job_id":null,"html_url":"https://github.com/yurifari/django-3t","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yurifari/django-3t","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurifari%2Fdjango-3t","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurifari%2Fdjango-3t/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurifari%2Fdjango-3t/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurifari%2Fdjango-3t/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yurifari","download_url":"https://codeload.github.com/yurifari/django-3t/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurifari%2Fdjango-3t/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","templates","testing"],"created_at":"2026-01-14T09:52:38.326Z","updated_at":"2026-01-14T09:52:39.822Z","avatar_url":"https://github.com/yurifari.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://img.shields.io/pypi/v/django-3t\n    :alt: PyPI Version\n    :target: https://pypi.python.org/pypi/pytest-3t\n\n.. image:: https://img.shields.io/travis/yurifari/django-3t\n    :alt: Travis Build\n    :target: https://travis-ci.org/yurifari/django-3t\n\n.. image:: https://img.shields.io/codecov/c/github/yurifari/django-3t\n    :alt: Code Coverage\n    :target: https://codecov.io/gh/yurifari/django-3t\n\n.. image:: https://img.shields.io/github/license/yurifari/django-3t\n    :alt: License\n    :target: https://github.com/yurifari/django-3t\n\nDjango 3T\n#########\n\nDjango 3T is a Django Template Testing Tool which aims to help developers to write better tests where the Django template engine is involved.\n\nSome of the things you can do with Django 3T include:\n\n- Ensure a specific ``template``, ``node`` or ``block`` is rendered\n- Ensure a specific ``template``, ``node`` or ``block`` is rendered a specific amount of times\n- Ensure a specific ``template`` is rendered with a specific context subset\n- Ensure a specific ``node`` is rendered with specific arguments\n- Ensure a specific ``template``, ``node`` or ``block`` results in a specific content or includes it\n\n.. _installation:\n\nInstallation\n************\n::\n\n    pip install django-3t\n\n.. _usage:\n\nUsage\n*****\nDjango 3T uses the ``watch_templates`` context manager to intercept template and node renderings.\n\nSuppose your project implements the following template called ``homepage.html``:\n\n.. code-block:: html\n\n    {% load say_hello from project_tags %}\n    \n    \u003ch1\u003eThe most useful website ever\u003c/h1\u003e\n    \n    {% say_hello request.user %}\n\nA test that makes sure your template and template tag are rendered correctly would roughly look like this:\n\n.. code-block:: python\n\n    from django.contrib.auth import get_user_model\n    from django.test import Client\n    \n    # 1. Import the context manager\n    from d3t.watcher import watch_templates\n    \n    User = get_user_model()\n    \n    def test_homepage():\n        user = User.objects.get(username='Billy')\n        client = Client()\n        client.force_login(user)\n        \n        # 2. Wrap the code where the rendering happens\n        with watch_templates as rendered:\n            client.get('/')\n    \n        # 3. Assert!\n        assert rendered.template('homepage.html')\n        assert rendered.node('say_hello').with_arguments(user)\n\nThe first assertion makes sure the template ``homepage.html`` was rendered, the second assertion makes sure the template tag ``say_hello`` was rendered and it was done using ``user`` as argument.\n\nFor a comprehensive list of available methods, check the `API section \u003capi_\u003e`_.\n\n.. _api:\n\nAPI\n***\nYou can check that a template, node or block has been rendered and that it did under specific conditions\n\n.. _template-api:\n\nTemplate API\n=================\nCheck that it has been rendered\n\n.. code-block:: python\n\n    rendered.template('template-name.html')\n\nCheck that it has been rendered with a specific context subset\n\n.. code-block:: python\n\n    rendered.template('template-name.html').with_context({'answer': 42})\n\nCheck that it has been rendered and the output contains a specific string\n\n.. code-block:: python\n\n    rendered.template('template-name.html').contains('content')\n\nCheck that it has been rendered and the output equals a specific string\n\n.. code-block:: python\n\n    rendered.template('template-name.html').equals('full content')\n\n.. _node-api:\n\nNode API\n=================\nCheck that it has been rendered\n\n.. code-block:: python\n\n    rendered.node('node_name')\n\nCheck that it has been rendered with specific arguments\n\n.. code-block:: python\n\n    rendered.node('node_name').with_arguments(42, type='answer')\n\nCheck that it has been rendered and the output contains a specific string\n\n.. code-block:: python\n\n    rendered.node('node_name').contains('content')\n\nCheck that it has been rendered and the output equals a specific string\n\n.. code-block:: python\n\n    rendered.node('node_name').equals('full content')\n\n.. _block-api:\n\nBlock API\n=================\nCheck that it has been rendered\n\n.. code-block:: python\n\n    rendered.block('block-name')\n\nCheck that it has been rendered and the output contains a specific string\n\n.. code-block:: python\n\n    rendered.block('block-name').contains('content')\n\nCheck that it has been rendered and the output equals a specific string\n\n.. code-block:: python\n\n    rendered.block('block-name').equals('full content')\n\n.. _handling-multiple-renderings:\n\nHandling multilpe renderings\n============================\n\nA template, node or block could be rendered any number of times, Django 3T allows you to take control of this giving support for the ``not`` operator and for the ``len``, ``all`` and ``any`` built-in functions:\n\nCheck that a template/node/block has not been rendered\n\n.. code-block:: python\n\n    not rendered.template('template-name.html')\n\nCheck that a template/node/block has been rendered a specific amount of times\n\n.. code-block:: python\n\n    len(rendered.node('node_name')) == 3\n\nCheck that all the template/node/block renderings happened under a specific condition\n\n.. code-block:: python\n\n    all(rendered.block('block-name').contains('content'))\n\nCheck that any of the template/node/block renderings happened under a specific condition\n\n.. code-block:: python\n\n    any(rendered.template('template-name.html').equals('specific content'))\n\n.. _signals:\n\nSignals\n*******\ntemplate_rendered\n=================\n``d3t.signals.template_rendered``\n\nThis is sent immediately after a template is rendered.\n\nArguments sent with this signal:\n\n- | **sender**\n  | The ``Template`` class.\n\n- | **instance**\n  | The actual template instance being rendered.\n\n- | **context**\n  | The context used to render the template.\n\n- | **result**\n  | The resulting rendered output.\n\nnode_rendered\n=================\n``d3t.signals.node_rendered``\n\nThis is sent immediately after a node is rendered.\n\nArguments sent with this signal:\n\n- | **sender**\n  | The ``Node`` class.\n\n- | **instance**\n  | The actual node instance being rendered.\n\n- | **result**\n  | The resulting rendered output.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurifari%2Fdjango-3t","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyurifari%2Fdjango-3t","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurifari%2Fdjango-3t/lists"}