bupytest


Namebupytest JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/jaedsonpys/bupytest
SummaryPerform fast and detailed unit tests with BuPyTest.
upload_time2023-02-04 15:54:47
maintainer
docs_urlNone
authorJaedson Silva
requires_python
licenseGPL-3.0
keywords test unittest python tdd unit sequential
VCS
bugtrack_url
requirements argeasy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BuPyTest - Unit Tests

BuPyTest is a library to perform **unit tests** on your code by classes. You can create tests using classes and run them together in a single file.

With `bupytest`, you can implement [**git hooks**](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run tests using [Command Line](#command-line).

- [X] Test multiple files using **command line**;
- [x] Test only one file using **command line**;
- [x] Test **multiple classes** in one file;
- [x] Test using command line.

You can install the **latest version** of BuPyTest using the `pip` package manager:

```commandline
pip install bupytest
```

## How to use

Here's a simple tutorial on how to use `bupytest` in your tests:

> In the base class `bupytest.BaseTest` all tests are executed in the order they were defined (sequential).

```python
import bupytest


class TestFoo(bupytest.UnitTest):
    def __init__(self):
        super().__init__()

    def test_1(self):
        self.assert_true(True, message='A error ocurred')

    def test_2(self):
        false_value = ''
        self.assert_false(false_value, message='Empty string')


if __name__ == '__main__':
    bupytest.this()
```

With `bupytest`, you define test classes and the methods, which will be tested. To test a value, you can use the following methods of the `bupytest.UnitTest` class:

- `UnitTest.assert_true`: asserts a true value;
- `UnitTest.assert_false`: asserts a false value;
- `UnitTest.assert_expected`: asserts an expected value.

All test classes must **start with "Test"**, and all test class methods must **start with "test_"**.

At the end of the file, the `bupytest.this` method runs the test **in this** file. That is, all test classes in this file will be executed.

You can also define several other classes in the same file for testing:

```python
import bupytest


class TestFoo(bupytest.UnitTest):
    def __init__(self):
        super().__init__()

    def test_1(self):
        self.assert_true(True, message='A error ocurred')

    def test_2(self):
        false_value = ''
        self.assert_false(false_value, message='Empty string')


class TestBar(bupytest.UnitTest):
    def __init__(self):
        super().__init__()

    def test_1(self):
        self.assert_expected('hello', 'hello')


if __name__ == '__main__':
    bupytest.this()
```

## Command Line

`bupytest` also has a **command line** application available to run tests, the script is called `bupytest`, see some **commands** and **flags** (use `--help` to get help):

Just use the `test` command to test one module or a directory with multiple modules. Here is an example:

```commandline
bupytest test test_cookiedb.py
```

Now testing multiple test modules inside a directory:

```commandline
bupytest test tests/
```

To test multiple modules from a directory, as in the example above, the name of the modules to be tested **must** start with `test_`, otherwise the test **will not run. 

## License

```text
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
```

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jaedsonpys/bupytest",
    "name": "bupytest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "test,unittest,python,tdd,unit,sequential",
    "author": "Jaedson Silva",
    "author_email": "imunknowuser@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f3/8e/76b5e8e65dc5bc7fb265ab7057185d40ede2d5ef9594bd0c64547a24a4be/bupytest-1.3.1.tar.gz",
    "platform": null,
    "description": "# BuPyTest - Unit Tests\n\nBuPyTest is a library to perform **unit tests** on your code by classes. You can create tests using classes and run them together in a single file.\n\nWith `bupytest`, you can implement [**git hooks**](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run tests using [Command Line](#command-line).\n\n- [X] Test multiple files using **command line**;\n- [x] Test only one file using **command line**;\n- [x] Test **multiple classes** in one file;\n- [x] Test using command line.\n\nYou can install the **latest version** of BuPyTest using the `pip` package manager:\n\n```commandline\npip install bupytest\n```\n\n## How to use\n\nHere's a simple tutorial on how to use `bupytest` in your tests:\n\n> In the base class `bupytest.BaseTest` all tests are executed in the order they were defined (sequential).\n\n```python\nimport bupytest\n\n\nclass TestFoo(bupytest.UnitTest):\n    def __init__(self):\n        super().__init__()\n\n    def test_1(self):\n        self.assert_true(True, message='A error ocurred')\n\n    def test_2(self):\n        false_value = ''\n        self.assert_false(false_value, message='Empty string')\n\n\nif __name__ == '__main__':\n    bupytest.this()\n```\n\nWith `bupytest`, you define test classes and the methods, which will be tested. To test a value, you can use the following methods of the `bupytest.UnitTest` class:\n\n- `UnitTest.assert_true`: asserts a true value;\n- `UnitTest.assert_false`: asserts a false value;\n- `UnitTest.assert_expected`: asserts an expected value.\n\nAll test classes must **start with \"Test\"**, and all test class methods must **start with \"test_\"**.\n\nAt the end of the file, the `bupytest.this` method runs the test **in this** file. That is, all test classes in this file will be executed.\n\nYou can also define several other classes in the same file for testing:\n\n```python\nimport bupytest\n\n\nclass TestFoo(bupytest.UnitTest):\n    def __init__(self):\n        super().__init__()\n\n    def test_1(self):\n        self.assert_true(True, message='A error ocurred')\n\n    def test_2(self):\n        false_value = ''\n        self.assert_false(false_value, message='Empty string')\n\n\nclass TestBar(bupytest.UnitTest):\n    def __init__(self):\n        super().__init__()\n\n    def test_1(self):\n        self.assert_expected('hello', 'hello')\n\n\nif __name__ == '__main__':\n    bupytest.this()\n```\n\n## Command Line\n\n`bupytest` also has a **command line** application available to run tests, the script is called `bupytest`, see some **commands** and **flags** (use `--help` to get help):\n\nJust use the `test` command to test one module or a directory with multiple modules. Here is an example:\n\n```commandline\nbupytest test test_cookiedb.py\n```\n\nNow testing multiple test modules inside a directory:\n\n```commandline\nbupytest test tests/\n```\n\nTo test multiple modules from a directory, as in the example above, the name of the modules to be tested **must** start with `test_`, otherwise the test **will not run. \n\n## License\n\n```text\nGNU GENERAL PUBLIC LICENSE\nVersion 3, 29 June 2007\n```\n\nCopyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\nEveryone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "Perform fast and detailed unit tests with BuPyTest.",
    "version": "1.3.1",
    "split_keywords": [
        "test",
        "unittest",
        "python",
        "tdd",
        "unit",
        "sequential"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f38e76b5e8e65dc5bc7fb265ab7057185d40ede2d5ef9594bd0c64547a24a4be",
                "md5": "c39ac87607cad170d3b03cccf74e2442",
                "sha256": "6d71ee44ce2d3c8dbb4f22c31d23a9dd0a8fd5eb0c78b8df56c7ab8667e20598"
            },
            "downloads": -1,
            "filename": "bupytest-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c39ac87607cad170d3b03cccf74e2442",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5290,
            "upload_time": "2023-02-04T15:54:47",
            "upload_time_iso_8601": "2023-02-04T15:54:47.019393Z",
            "url": "https://files.pythonhosted.org/packages/f3/8e/76b5e8e65dc5bc7fb265ab7057185d40ede2d5ef9594bd0c64547a24a4be/bupytest-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-04 15:54:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jaedsonpys",
    "github_project": "bupytest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "argeasy",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        }
    ],
    "lcname": "bupytest"
}
        
Elapsed time: 0.05073s