<div align="center">
<img height="180" alt="deflector Logo" src="https://raw.githubusercontent.com/richecr/deflector/main/.github/assets/readme/logo.png">
# Deflector
---
π [Documentation - Under Construction]()
</div>
---
## Why does Deflector exist?
π‘ **Deflector** is a minimalist testing library for Python designed to simplify test writing with a clear and intuitive syntax, allowing developers to create and run tests quickly and efficiently without unnecessary complications.
</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> High **isolation** level per file<br />
</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> **Fully typed** library<br />
---
## Quickstart
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> Install
```zsh
$ pip install deflector
```
Or with [poetry](https://python-poetry.org/docs/)
```zsh
poetry add deflector -G dev
```
---
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> Test
<table>
<tr>
<td>
<blockquote>tests/test_file1.py</blockquote>
</td>
</tr>
<tr>
<td width="1200">
```py
from deflector import affirm
affirm.equal(1, 1, "My first test with deflector")
```
</td>
</tr>
</table>
---
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> Run
```bash
deflector # or poetry run deflector
```
Or defining the directory where the tests are:
```bash
deflector --dir tests
```
---
## Features
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg"> Main
| Function | Description |
|--------------------------------------------------------|-------------------------------------------|
| [affirm](#affirm) | π Test assertion. |
| [it](#it) | π€Ήπ»ββοΈ Isolate tests. |
| [describe](#describe) | π€Ήπ»ββοΈ Grouping tests. |
| [before_each β’ after_each](#before-each--after-each) | π Functions for test setup and teardown. |
#### Affirm
The `affirm` is used to create tests that validate whether the behavior of your code is as expected, checking the correspondence between values ββand triggering errors if there are discrepancies.
```python
from deflector import affirm
```
| Function | Description |
|--------------------------------------------|----------------------------------------------|
| [ok](#ok) | Checks if a value is truthy. |
| [equal](#equals) | Compares if two values are equal. |
| [not_equal](#not-equals) | Verifies if two values are different. |
| [match_re](#match-regex) | Checks if a string matches a regex. |
| [does_not_match_re](#does-not-match-regex) | Verifies if a string does not match a regex. |
##### Ok
```python
affirm.ok(value, message)
```
```python
affirm.ok(True, "Ok")
```
##### Equals
```python
affirm.equal(value, expected, message)
```
```python
affirm.equal(1 + 2, 3, "Equal: Sum 1+2=3")
```
##### Not Equals
```python
affirm.not_equal(value, expected, message)
```
```python
affirm.not_equal(1 + 2, 4, "Not Equal: Sum 1+2!=4")
```
##### Match Regex
```python
affirm.match_re(value, reg_exp, message)
```
```python
affirm.match_re("acab", "ab", "Match Regex: ab in acab")
```
##### Does Not Match Regex
```python
affirm.does_not_match_re(value, reg_exp, message)
```
```python
affirm.does_not_match_re("ab", "abc", "Does Not Match Regex: ab not in a")
```
#### It
```python
from deflector import affirm, it
@it("It Test 1")
def test_1() -> None:
affirm.ok(True, "Ok")
affirm.equal(1 + 1, 2, "Equal")
affirm.not_equal(1 + 2, 1, "Not Equal")
affirm.match_re("acab", "ab", "Match Re")
affirm.does_not_match_re("a", "ab", "Does Not Match Re")
```
#### Describe
```python
from deflector import affirm, describe, it
@describe("Main 1")
def describe_main() -> None:
@it("It Test 1")
def test1() -> None:
affirm.equal(1 + 1, 2, "Equal 1+1=2")
@it("It Test 2")
def test2() -> None:
affirm.match_re("acab", "ab", "Match Re")
```
#### Before Each β’ After Each
```python
from deflector import affirm, describe, it
@describe("Main 1")
def describe_main() -> None:
x = 1
@before_each()
async def start() -> bool:
nonlocal x
await asyncio.sleep(1)
x += 1
return True
@after_each()
async def end_() -> bool:
nonlocal x
await asyncio.sleep(1)
x = 1
return True
@it("It Test 1")
def test1() -> None:
affirm.equal(x, 2, "Equal Before Each")
affirm.equal(1 + 1, 2, "Equal 1")
affirm.equal(1 + 1, 2, "Equal 2")
@it("It Test 2")
def test2() -> None:
affirm.equal(x, 2, "Equal After Each")
affirm.equal(1 + 1, 2, "Equal")
affirm.not_equal(1 + 1, 1, "Not Equal")
affirm.ok(True, "Ok")
affirm.match_re("acab", "ab", "Match Re")
affirm.does_not_match_re("a", "ab", "Does Not Match Re")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/richecr/deflector",
"name": "deflector",
"maintainer": "Rich Ramalho",
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": "richecr1799@gmail.com",
"keywords": "test, ent-2-end, unit tests, assert, equal, ensure, affirm, validation, python",
"author": "Rich Ramalho",
"author_email": "richecr1799@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8e/ec/327cbaeb219e47519d176076dc5d6f00cfb3ac8802e40d944f43421e1cb8/deflector-0.1.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n<img height=\"180\" alt=\"deflector Logo\" src=\"https://raw.githubusercontent.com/richecr/deflector/main/.github/assets/readme/logo.png\">\n\n# Deflector\n\n---\n\n\ud83d\udcd8 [Documentation - Under Construction]()\n\n</div>\n\n---\n\n## Why does Deflector exist?\n\n\ud83d\udca1 **Deflector** is a minimalist testing library for Python designed to simplify test writing with a clear and intuitive syntax, allowing developers to create and run tests quickly and efficiently without unnecessary complications.\n\n</span><img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> High **isolation** level per file<br />\n</span><img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> **Performant** and **lightweight**<br />\n</span><img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> **Fully typed** library<br />\n\n---\n\n## Quickstart\n\n### <img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> Install\n\n\n```zsh\n$ pip install deflector\n```\n\nOr with [poetry](https://python-poetry.org/docs/)\n\n```zsh\npoetry add deflector -G dev\n```\n\n---\n\n### <img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> Test\n\n<table>\n<tr>\n<td>\n<blockquote>tests/test_file1.py</blockquote>\n</td>\n</tr>\n<tr>\n<td width=\"1200\">\n\n```py\nfrom deflector import affirm\n\n\naffirm.equal(1, 1, \"My first test with deflector\")\n```\n\n</td>\n</tr>\n</table>\n\n---\n\n### <img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> Run\n\n\n```bash\ndeflector # or poetry run deflector\n```\n\nOr defining the directory where the tests are:\n\n```bash\ndeflector --dir tests\n```\n\n---\n\n## Features\n\n### <img width=\"16\" height=\"16\" alt=\"check\" src=\"https://raw.githubusercontent.com/richecr/deflector/91367ebe4c1d82e3d86c92647b391fd1840d6c13/.github/assets/readme/check.svg\"> Main\n\n| Function | Description |\n|--------------------------------------------------------|-------------------------------------------|\n| [affirm](#affirm) | \ud83d\udd0d Test assertion. |\n| [it](#it) | \ud83e\udd39\ud83c\udffb\u200d\u2640\ufe0f Isolate tests. |\n| [describe](#describe) | \ud83e\udd39\ud83c\udffb\u200d\u2640\ufe0f Grouping tests. |\n| [before_each \u2022 after_each](#before-each--after-each) | \ud83c\udccf Functions for test setup and teardown. |\n\n\n#### Affirm\n\nThe `affirm` is used to create tests that validate whether the behavior of your code is as expected, checking the correspondence between values \u200b\u200band triggering errors if there are discrepancies.\n\n```python\nfrom deflector import affirm\n```\n\n| Function | Description |\n|--------------------------------------------|----------------------------------------------|\n| [ok](#ok) | Checks if a value is truthy. |\n| [equal](#equals) | Compares if two values are equal. |\n| [not_equal](#not-equals) | Verifies if two values are different. |\n| [match_re](#match-regex) | Checks if a string matches a regex. |\n| [does_not_match_re](#does-not-match-regex) | Verifies if a string does not match a regex. |\n\n##### Ok\n\n```python\naffirm.ok(value, message)\n```\n\n```python\naffirm.ok(True, \"Ok\")\n```\n\n##### Equals\n\n```python\naffirm.equal(value, expected, message)\n```\n\n```python\naffirm.equal(1 + 2, 3, \"Equal: Sum 1+2=3\")\n```\n\n##### Not Equals\n\n```python\naffirm.not_equal(value, expected, message)\n```\n\n```python\naffirm.not_equal(1 + 2, 4, \"Not Equal: Sum 1+2!=4\")\n```\n\n##### Match Regex\n\n```python\naffirm.match_re(value, reg_exp, message)\n```\n\n```python\naffirm.match_re(\"acab\", \"ab\", \"Match Regex: ab in acab\")\n```\n\n##### Does Not Match Regex\n\n```python\naffirm.does_not_match_re(value, reg_exp, message)\n```\n\n```python\naffirm.does_not_match_re(\"ab\", \"abc\", \"Does Not Match Regex: ab not in a\")\n```\n\n#### It\n\n```python\nfrom deflector import affirm, it\n\n@it(\"It Test 1\")\ndef test_1() -> None:\n affirm.ok(True, \"Ok\")\n affirm.equal(1 + 1, 2, \"Equal\")\n affirm.not_equal(1 + 2, 1, \"Not Equal\")\n affirm.match_re(\"acab\", \"ab\", \"Match Re\")\n affirm.does_not_match_re(\"a\", \"ab\", \"Does Not Match Re\")\n```\n\n#### Describe\n\n```python\nfrom deflector import affirm, describe, it\n\n@describe(\"Main 1\")\ndef describe_main() -> None:\n @it(\"It Test 1\")\n def test1() -> None:\n affirm.equal(1 + 1, 2, \"Equal 1+1=2\")\n\n @it(\"It Test 2\")\n def test2() -> None:\n affirm.match_re(\"acab\", \"ab\", \"Match Re\")\n```\n\n#### Before Each \u2022 After Each\n\n```python\nfrom deflector import affirm, describe, it\n\n@describe(\"Main 1\")\ndef describe_main() -> None:\n x = 1\n\n @before_each()\n async def start() -> bool:\n nonlocal x\n await asyncio.sleep(1)\n x += 1\n return True\n\n @after_each()\n async def end_() -> bool:\n nonlocal x\n await asyncio.sleep(1)\n x = 1\n return True\n\n @it(\"It Test 1\")\n def test1() -> None:\n affirm.equal(x, 2, \"Equal Before Each\")\n affirm.equal(1 + 1, 2, \"Equal 1\")\n affirm.equal(1 + 1, 2, \"Equal 2\")\n\n @it(\"It Test 2\")\n def test2() -> None:\n affirm.equal(x, 2, \"Equal After Each\")\n affirm.equal(1 + 1, 2, \"Equal\")\n affirm.not_equal(1 + 1, 1, \"Not Equal\")\n affirm.ok(True, \"Ok\")\n affirm.match_re(\"acab\", \"ab\", \"Match Re\")\n affirm.does_not_match_re(\"a\", \"ab\", \"Does Not Match Re\")\n```",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "Deflector is a minimalist testing library for Python designed to simplify test writing with a clear and intuitive syntax, allowing developers to create and run tests quickly and efficiently without unnecessary complications.",
"version": "0.1.1",
"project_urls": {
"Documentation": "https://github.com/richecr/deflector",
"Homepage": "https://github.com/richecr/deflector",
"Repository": "https://github.com/richecr/deflector"
},
"split_keywords": [
"test",
" ent-2-end",
" unit tests",
" assert",
" equal",
" ensure",
" affirm",
" validation",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e04c44e9f5869caf443967c2cf0e2c7c9b97e280aad9c0c40c9676665fabaee0",
"md5": "452db6deff9ac6c254ad89d2163be01b",
"sha256": "f88577e2f52841ef32386ce9737f7342c0b7c0cbad8bafebfd183f6e39ba1419"
},
"downloads": -1,
"filename": "deflector-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "452db6deff9ac6c254ad89d2163be01b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 12329,
"upload_time": "2024-09-09T02:06:33",
"upload_time_iso_8601": "2024-09-09T02:06:33.531140Z",
"url": "https://files.pythonhosted.org/packages/e0/4c/44e9f5869caf443967c2cf0e2c7c9b97e280aad9c0c40c9676665fabaee0/deflector-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8eec327cbaeb219e47519d176076dc5d6f00cfb3ac8802e40d944f43421e1cb8",
"md5": "fe781cfa93c092082204fccc3f4b9a22",
"sha256": "9f977f1e547c8a54fd29b8d0e8fac47413a532f37155319023fdeebb1e12a56f"
},
"downloads": -1,
"filename": "deflector-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "fe781cfa93c092082204fccc3f4b9a22",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 8873,
"upload_time": "2024-09-09T02:06:35",
"upload_time_iso_8601": "2024-09-09T02:06:35.062658Z",
"url": "https://files.pythonhosted.org/packages/8e/ec/327cbaeb219e47519d176076dc5d6f00cfb3ac8802e40d944f43421e1cb8/deflector-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-09 02:06:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "richecr",
"github_project": "deflector",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "deflector"
}