Skip to main content

Simple TestCase assertion that finds element based on it's path and check if it equals with given content.

Project description

https://badge.fury.io/py/assert_element.svg https://codecov.io/gh/PetrDlouhy/assert_element/branch/master/graph/badge.svg https://github.com/PetrDlouhy/django-assert-element/actions/workflows/main.yml/badge.svg?event=registry_package

Simple TestCase assertion that finds element based on it’s path and check if it equals with given content.

This is more useful than the default Django AssertContains because it will find the element and show differences if something changed. The test also tries to ignore differences in whitespaces as much as possible.

Documentation

The full documentation is at https://assert_element.readthedocs.io.

Quickstart

Usage in tests:

from assert_element import AssertElementMixin

class MyTestCase(AssertElementMixin, TestCase):
    def test_something(self):
        response = self.client.get(address)
        self.assertElementContains(
            response,
            'div[id="my-div"]',
            '<div id="my-div">My div</div>',
        )

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Development commands

pip install -r requirements_dev.txt
invoke -l

Credits

Tools used in rendering this package:

History

0.1.0 (2022-08-21)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

assert_element-0.1.1.tar.gz (18.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page