morelia


Namemorelia JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://github.com/kidosoft/morelia
Summaryfor "Behavior Driven Development" (BDD) -- a client-facing scripting language to put the squeeze on all your features
upload_time2024-03-03 20:37:51
maintainer
docs_urlNone
authordryobates
requires_python>=3.8,<4.0
licenseMIT
keywords test bdd behavior
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            #######
Morelia
#######

.. image:: https://img.shields.io/pypi/wheel/Morelia.svg
    :target: https://pypi.python.org/pypi/Morelia/
    :alt: Wheel Status

.. image:: https://img.shields.io/pypi/pyversions/Morelia.svg
    :target: https://pypi.python.org/pypi/Morelia/
    :alt: Python versions

.. image:: https://img.shields.io/pypi/v/Morelia.svg
    :target: https://pypi.python.org/pypi/Morelia/
    :alt: Latest Version

.. image:: https://img.shields.io/pypi/l/Morelia.svg
    :target: https://pypi.python.org/pypi/Morelia/
    :alt: License

.. image:: https://readthedocs.org/projects/morelia/badge/?format=svg
    :target: https://morelia.readthedocs.io
    :alt: Documentation

.. image:: https://pyup.io/repos/github/kidosoft/Morelia/shield.svg
    :target: https://pyup.io/repos/github/kidosoft/Morelia/
    :alt: Updates

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/ambv/black

Morelia is a Python Behavior Driven Development (BDD) library.

BDD is an agile software development process that encourages
collaboration between developers, QA and business participants.

Test scenarios written in natural language make BDD foundation.
They are comprehensible for non-technical participants who wrote them
and unambiguous for developers and QA.

Morelia makes it easy for developers to integrate BDD into their existing
unittest frameworks.  It is easy to run under nose, pytest, tox, trial or integrate
with django, flask or any other python framework because no special code
have to be written.

You as developer are in charge of how tests are organized. No need to fit into
rigid rules forced by some other BDD frameworks.

**Mascot**:

.. image:: http://www.naturfoto.cz/fotografie/ostatni/krajta-zelena-47784.jpg

Installation
============

.. code-block:: console

    pip install morelia

Quick usage guide
=================

Write a feature description:

.. code-block:: cucumber

    # calculator.feature

    Feature: Addition
        In order to avoid silly mistakes
        As a math idiot
        I want to be told the sum of two numbers

    Scenario: Add two numbers
        Given I have powered calculator on
        When I enter "50" into the calculator
        And I enter "70" into the calculator
        And I press add
        Then the result should be "120" on the screen


Create standard Python's `unittest` and hook Morelia into it:

.. code-block:: python

    # test_acceptance.py

    import unittest

    from morelia import verify


    class CalculatorTestCase(unittest.TestCase):

        def test_addition(self):
            """ Addition feature """
            verify('calculator.feature', self)

Run test with your favourite runner: unittest, nose, py.test, trial. You name it!

.. code-block:: console

    $ python -m unittest -v test_acceptance  # or
    $ pytest test_acceptance.py  # or
    $ nosetests -v test_acceptance.py  # or
    $ trial test_acceptance.py  # or
    $ # django/pyramid/flask/(place for your favourite test runner)

And you'll see which steps are missing:

.. code-block:: python

    F
    ======================================================================
    FAIL: test_addition (test_acceptance.CalculatorTestCase)
    Addition feature.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "(..)test_acceptance.py", line 31, in test_addition
        verify(filename, self)
      File "(..)/morelia/__init__.py", line 120, in verify
        execute_script(feature, suite, scenario=scenario, config=conf)
      File "(..)/morelia/parser.py", line 59, in execute_script
        assert not_found == set(), message
    AssertionError: Cannot match steps:

        def step_I_have_powered_calculator_on(self):
            r'I have powered calculator on'

            raise NotImplementedError('I have powered calculator on')

        def step_I_enter_number_into_the_calculator(self, number):
            r'I enter "([^"]+)" into the calculator'

            raise NotImplementedError('I enter "50" into the calculator')

        def step_I_enter_number_into_the_calculator(self, number):
            r'I enter "([^"]+)" into the calculator'

            raise NotImplementedError('I enter "70" into the calculator')

        def step_I_press_add(self):
            r'I press add'

            raise NotImplementedError('I press add')

        def step_the_result_should_be_number_on_the_screen(self, number):
            r'the result should be "([^"]+)" on the screen'

            raise NotImplementedError('the result should be "120" on the screen')

    ----------------------------------------------------------------------
    Ran 1 test in 0.013s

    FAILED (failures=1)

Now implement steps with standard `TestCases` that you are familiar:

.. code-block:: python

    # test_acceptance.py

    import unittest

    from morelia import verify


    class CalculatorTestCase(unittest.TestCase):

        def test_addition(self):
            """ Addition feature """
            verify('calculator.feature', self)

        def step_I_have_powered_calculator_on(self):
            r'I have powered calculator on'
            self.stack = []

        def step_I_enter_a_number_into_the_calculator(self, number):
            r'I enter "(\d+)" into the calculator'  # match by regexp
            self.stack.append(int(number))

        def step_I_press_add(self):  # matched by method name
            self.result = sum(self.stack)

        def step_the_result_should_be_on_the_screen(self, number):
            r'the result should be "{number}" on the screen'  # match by format-like string
            self.assertEqual(int(number), self.result)


And run it again:

.. code-block:: console

    $ python -m unittest test_acceptance

    Feature: Addition
        In order to avoid silly mistakes
        As a math idiot
        I want to be told the sum of two numbers
    Scenario: Add two numbers
        Given I have powered calculator on                       # pass  0.000s
        When I enter "50" into the calculator                    # pass  0.000s
        And I enter "70" into the calculator                     # pass  0.000s
        And I press add                                          # pass  0.001s
        Then the result should be "120" on the screen            # pass  0.001s
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.028s

    OK

Note that Morelia does not waste anyone's time inventing a new testing back-end
just to add a layer of literacy over our testage. Steps are miniature `TestCases`.
Your onsite customer need never know, and your unit tests and customer tests
can share their support methods. The same one test button can run all TDD and BDD tests.

Look at example directory for a little more enhanced example and read full
documentation for more advanced topics.

Documentation
=============

Full documentation is available at http://morelia.readthedocs.org/en/latest/index.html

Credits
---------

This package was created with Cookiecutter_ and the `kidosoft/cookiecutter-pypackage`_ project template.

[ ~ Dependencies scanned by `PyUp.io`_ ~ ]

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`kidosoft/cookiecutter-pypackage`: https://github.com/kidosoft/cookiecutter-pypackage
.. _`PyUp.io`: https://pyup.io/


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kidosoft/morelia",
    "name": "morelia",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "test,bdd,behavior",
    "author": "dryobates",
    "author_email": "jakub.stolarski@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e4/d2/19c62ec44417d00957a115274ef8807fc0421f7ec7487bdc58955180681f/morelia-0.10.0.tar.gz",
    "platform": null,
    "description": "#######\nMorelia\n#######\n\n.. image:: https://img.shields.io/pypi/wheel/Morelia.svg\n    :target: https://pypi.python.org/pypi/Morelia/\n    :alt: Wheel Status\n\n.. image:: https://img.shields.io/pypi/pyversions/Morelia.svg\n    :target: https://pypi.python.org/pypi/Morelia/\n    :alt: Python versions\n\n.. image:: https://img.shields.io/pypi/v/Morelia.svg\n    :target: https://pypi.python.org/pypi/Morelia/\n    :alt: Latest Version\n\n.. image:: https://img.shields.io/pypi/l/Morelia.svg\n    :target: https://pypi.python.org/pypi/Morelia/\n    :alt: License\n\n.. image:: https://readthedocs.org/projects/morelia/badge/?format=svg\n    :target: https://morelia.readthedocs.io\n    :alt: Documentation\n\n.. image:: https://pyup.io/repos/github/kidosoft/Morelia/shield.svg\n    :target: https://pyup.io/repos/github/kidosoft/Morelia/\n    :alt: Updates\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/ambv/black\n\nMorelia is a Python Behavior Driven Development (BDD) library.\n\nBDD is an agile software development process that encourages\ncollaboration between developers, QA and business participants.\n\nTest scenarios written in natural language make BDD foundation.\nThey are comprehensible for non-technical participants who wrote them\nand unambiguous for developers and QA.\n\nMorelia makes it easy for developers to integrate BDD into their existing\nunittest frameworks.  It is easy to run under nose, pytest, tox, trial or integrate\nwith django, flask or any other python framework because no special code\nhave to be written.\n\nYou as developer are in charge of how tests are organized. No need to fit into\nrigid rules forced by some other BDD frameworks.\n\n**Mascot**:\n\n.. image:: http://www.naturfoto.cz/fotografie/ostatni/krajta-zelena-47784.jpg\n\nInstallation\n============\n\n.. code-block:: console\n\n    pip install morelia\n\nQuick usage guide\n=================\n\nWrite a feature description:\n\n.. code-block:: cucumber\n\n    # calculator.feature\n\n    Feature: Addition\n        In order to avoid silly mistakes\n        As a math idiot\n        I want to be told the sum of two numbers\n\n    Scenario: Add two numbers\n        Given I have powered calculator on\n        When I enter \"50\" into the calculator\n        And I enter \"70\" into the calculator\n        And I press add\n        Then the result should be \"120\" on the screen\n\n\nCreate standard Python's `unittest` and hook Morelia into it:\n\n.. code-block:: python\n\n    # test_acceptance.py\n\n    import unittest\n\n    from morelia import verify\n\n\n    class CalculatorTestCase(unittest.TestCase):\n\n        def test_addition(self):\n            \"\"\" Addition feature \"\"\"\n            verify('calculator.feature', self)\n\nRun test with your favourite runner: unittest, nose, py.test, trial. You name it!\n\n.. code-block:: console\n\n    $ python -m unittest -v test_acceptance  # or\n    $ pytest test_acceptance.py  # or\n    $ nosetests -v test_acceptance.py  # or\n    $ trial test_acceptance.py  # or\n    $ # django/pyramid/flask/(place for your favourite test runner)\n\nAnd you'll see which steps are missing:\n\n.. code-block:: python\n\n    F\n    ======================================================================\n    FAIL: test_addition (test_acceptance.CalculatorTestCase)\n    Addition feature.\n    ----------------------------------------------------------------------\n    Traceback (most recent call last):\n      File \"(..)test_acceptance.py\", line 31, in test_addition\n        verify(filename, self)\n      File \"(..)/morelia/__init__.py\", line 120, in verify\n        execute_script(feature, suite, scenario=scenario, config=conf)\n      File \"(..)/morelia/parser.py\", line 59, in execute_script\n        assert not_found == set(), message\n    AssertionError: Cannot match steps:\n\n        def step_I_have_powered_calculator_on(self):\n            r'I have powered calculator on'\n\n            raise NotImplementedError('I have powered calculator on')\n\n        def step_I_enter_number_into_the_calculator(self, number):\n            r'I enter \"([^\"]+)\" into the calculator'\n\n            raise NotImplementedError('I enter \"50\" into the calculator')\n\n        def step_I_enter_number_into_the_calculator(self, number):\n            r'I enter \"([^\"]+)\" into the calculator'\n\n            raise NotImplementedError('I enter \"70\" into the calculator')\n\n        def step_I_press_add(self):\n            r'I press add'\n\n            raise NotImplementedError('I press add')\n\n        def step_the_result_should_be_number_on_the_screen(self, number):\n            r'the result should be \"([^\"]+)\" on the screen'\n\n            raise NotImplementedError('the result should be \"120\" on the screen')\n\n    ----------------------------------------------------------------------\n    Ran 1 test in 0.013s\n\n    FAILED (failures=1)\n\nNow implement steps with standard `TestCases` that you are familiar:\n\n.. code-block:: python\n\n    # test_acceptance.py\n\n    import unittest\n\n    from morelia import verify\n\n\n    class CalculatorTestCase(unittest.TestCase):\n\n        def test_addition(self):\n            \"\"\" Addition feature \"\"\"\n            verify('calculator.feature', self)\n\n        def step_I_have_powered_calculator_on(self):\n            r'I have powered calculator on'\n            self.stack = []\n\n        def step_I_enter_a_number_into_the_calculator(self, number):\n            r'I enter \"(\\d+)\" into the calculator'  # match by regexp\n            self.stack.append(int(number))\n\n        def step_I_press_add(self):  # matched by method name\n            self.result = sum(self.stack)\n\n        def step_the_result_should_be_on_the_screen(self, number):\n            r'the result should be \"{number}\" on the screen'  # match by format-like string\n            self.assertEqual(int(number), self.result)\n\n\nAnd run it again:\n\n.. code-block:: console\n\n    $ python -m unittest test_acceptance\n\n    Feature: Addition\n        In order to avoid silly mistakes\n        As a math idiot\n        I want to be told the sum of two numbers\n    Scenario: Add two numbers\n        Given I have powered calculator on                       # pass  0.000s\n        When I enter \"50\" into the calculator                    # pass  0.000s\n        And I enter \"70\" into the calculator                     # pass  0.000s\n        And I press add                                          # pass  0.001s\n        Then the result should be \"120\" on the screen            # pass  0.001s\n    .\n    ----------------------------------------------------------------------\n    Ran 1 test in 0.028s\n\n    OK\n\nNote that Morelia does not waste anyone's time inventing a new testing back-end\njust to add a layer of literacy over our testage. Steps are miniature `TestCases`.\nYour onsite customer need never know, and your unit tests and customer tests\ncan share their support methods. The same one test button can run all TDD and BDD tests.\n\nLook at example directory for a little more enhanced example and read full\ndocumentation for more advanced topics.\n\nDocumentation\n=============\n\nFull documentation is available at http://morelia.readthedocs.org/en/latest/index.html\n\nCredits\n---------\n\nThis package was created with Cookiecutter_ and the `kidosoft/cookiecutter-pypackage`_ project template.\n\n[ ~ Dependencies scanned by `PyUp.io`_ ~ ]\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`kidosoft/cookiecutter-pypackage`: https://github.com/kidosoft/cookiecutter-pypackage\n.. _`PyUp.io`: https://pyup.io/\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "for \"Behavior Driven Development\" (BDD) -- a client-facing scripting language to put the squeeze on all your features",
    "version": "0.10.0",
    "project_urls": {
        "Documentation": "https://morelia.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/kidosoft/morelia",
        "Repository": "https://github.com/kidosoft/morelia"
    },
    "split_keywords": [
        "test",
        "bdd",
        "behavior"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4efa156cbe41d426311de7687746b1463267703beea788c9b233ebb32126e46",
                "md5": "de98d16966ac892553c0db2c0835bb25",
                "sha256": "ef28acb6779779e4fced13446fafb6a7abfb4d9a3a2643f109920cddf9ec0fe5"
            },
            "downloads": -1,
            "filename": "morelia-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de98d16966ac892553c0db2c0835bb25",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 31293,
            "upload_time": "2024-03-03T20:37:49",
            "upload_time_iso_8601": "2024-03-03T20:37:49.047696Z",
            "url": "https://files.pythonhosted.org/packages/f4/ef/a156cbe41d426311de7687746b1463267703beea788c9b233ebb32126e46/morelia-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4d219c62ec44417d00957a115274ef8807fc0421f7ec7487bdc58955180681f",
                "md5": "31c7b4280c55c06ff3e1aad651fa068f",
                "sha256": "7e05fa2547a0e36617d3fa32a21f79a3bb5cf63c07c70d9bd22fcd10f19ab036"
            },
            "downloads": -1,
            "filename": "morelia-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "31c7b4280c55c06ff3e1aad651fa068f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 29854,
            "upload_time": "2024-03-03T20:37:51",
            "upload_time_iso_8601": "2024-03-03T20:37:51.701128Z",
            "url": "https://files.pythonhosted.org/packages/e4/d2/19c62ec44417d00957a115274ef8807fc0421f7ec7487bdc58955180681f/morelia-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-03 20:37:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kidosoft",
    "github_project": "morelia",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "morelia"
}
        
Elapsed time: 0.52382s