astest


Nameastest JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/tusharsadhwani/astest
SummaryThe quick, easy way to write tests in Python.
upload_time2023-08-15 16:43:55
maintainer
docs_urlNone
authorTushar Sadhwani
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # astest: `assert` based testing

The quick, easy way to write tests in Python.

## Usage

Get the tool by installing it from `pip`:

```bash
pip install astest
```

The tool doesn't have to be installed in your project's environment, you can
also install it in your global Python (since it has no dependencies).

Then give it a file containing "tests" (explained below):

```bash
astest test_file.py
```

---

You can also easily run it via `pipx`:

```bash
pipx run astest test_file.py
```

### Test files

`astest` expects a file that does `assert`'s at runtime.

So to write a test for your code, simply do `assert`s in your file:

```python
from my_library import add

assert add(12, 13) == 25
assert add(33, 77) == 100  # This one is false
assert add(123, 123) == 246
```

Running this will look like this:

```console
$ astest examples/simple.py
Test 1..................................................................PASSED
Test 2..................................................................FAILED
Failing test: assert add(33, 77) == 100
Test 3..................................................................PASSED
===================== 1 failed, 2 passed in 0.00 seconds =====================
```

### Debugging

If a test fails and you wish to debug it, you can run `astest` with `--debug`:

```console
$ astest examples/simple.py
Test 1..................................................................PASSED
Test 2..................................................................FAILED
Failing test: assert add(33, 77) == 100
Starting debug session:
>>> add(33, 77)
110
>>> # Oh okay.
>>> ^D
Test 3..................................................................PASSED
===================== 1 failed, 2 passed in 0.00 seconds =====================
```

## Local Development / Testing

- Create and activate a virtual environment
- Run `pip install -r requirements-dev.txt` to do an editable install
- Run `pytest` to run tests

## Type Checking

Run `mypy .`

## Create and upload a package to PyPI

Make sure to bump the version in `setup.cfg`.

Then run the following commands:

```bash
rm -rf build dist
python setup.py sdist bdist_wheel
```

Then upload it to PyPI using [twine](https://twine.readthedocs.io/en/latest/#installation):

```bash
twine upload dist/*
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tusharsadhwani/astest",
    "name": "astest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tushar Sadhwani",
    "author_email": "tushar.sadhwani000@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/62/81/6197bab38d055d4326da2ffc9a0e4094b68d16ded3341946de6710468df1/astest-0.1.0.tar.gz",
    "platform": null,
    "description": "# astest: `assert` based testing\n\nThe quick, easy way to write tests in Python.\n\n## Usage\n\nGet the tool by installing it from `pip`:\n\n```bash\npip install astest\n```\n\nThe tool doesn't have to be installed in your project's environment, you can\nalso install it in your global Python (since it has no dependencies).\n\nThen give it a file containing \"tests\" (explained below):\n\n```bash\nastest test_file.py\n```\n\n---\n\nYou can also easily run it via `pipx`:\n\n```bash\npipx run astest test_file.py\n```\n\n### Test files\n\n`astest` expects a file that does `assert`'s at runtime.\n\nSo to write a test for your code, simply do `assert`s in your file:\n\n```python\nfrom my_library import add\n\nassert add(12, 13) == 25\nassert add(33, 77) == 100  # This one is false\nassert add(123, 123) == 246\n```\n\nRunning this will look like this:\n\n```console\n$ astest examples/simple.py\nTest 1..................................................................PASSED\nTest 2..................................................................FAILED\nFailing test: assert add(33, 77) == 100\nTest 3..................................................................PASSED\n===================== 1 failed, 2 passed in 0.00 seconds =====================\n```\n\n### Debugging\n\nIf a test fails and you wish to debug it, you can run `astest` with `--debug`:\n\n```console\n$ astest examples/simple.py\nTest 1..................................................................PASSED\nTest 2..................................................................FAILED\nFailing test: assert add(33, 77) == 100\nStarting debug session:\n>>> add(33, 77)\n110\n>>> # Oh okay.\n>>> ^D\nTest 3..................................................................PASSED\n===================== 1 failed, 2 passed in 0.00 seconds =====================\n```\n\n## Local Development / Testing\n\n- Create and activate a virtual environment\n- Run `pip install -r requirements-dev.txt` to do an editable install\n- Run `pytest` to run tests\n\n## Type Checking\n\nRun `mypy .`\n\n## Create and upload a package to PyPI\n\nMake sure to bump the version in `setup.cfg`.\n\nThen run the following commands:\n\n```bash\nrm -rf build dist\npython setup.py sdist bdist_wheel\n```\n\nThen upload it to PyPI using [twine](https://twine.readthedocs.io/en/latest/#installation):\n\n```bash\ntwine upload dist/*\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The quick, easy way to write tests in Python.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/tusharsadhwani/astest"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbd83b3f7e93f7c9af67980668da66645f857564fbf69f18925269e6578b805b",
                "md5": "ba72d3831034199ae29d1b333e4f9e0f",
                "sha256": "a70e631a2e924a3ea5c351465fe604ba08b9fcc2df02bdfb8def4ad30405f09f"
            },
            "downloads": -1,
            "filename": "astest-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ba72d3831034199ae29d1b333e4f9e0f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5648,
            "upload_time": "2023-08-15T16:43:53",
            "upload_time_iso_8601": "2023-08-15T16:43:53.885565Z",
            "url": "https://files.pythonhosted.org/packages/cb/d8/3b3f7e93f7c9af67980668da66645f857564fbf69f18925269e6578b805b/astest-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62816197bab38d055d4326da2ffc9a0e4094b68d16ded3341946de6710468df1",
                "md5": "75197847420f12003df34db08fd0d5e3",
                "sha256": "9fab8edd13fcd02ac5ed713a3baf99bf8c1a3e59fa380905b5de3ba59312668b"
            },
            "downloads": -1,
            "filename": "astest-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "75197847420f12003df34db08fd0d5e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4953,
            "upload_time": "2023-08-15T16:43:55",
            "upload_time_iso_8601": "2023-08-15T16:43:55.618349Z",
            "url": "https://files.pythonhosted.org/packages/62/81/6197bab38d055d4326da2ffc9a0e4094b68d16ded3341946de6710468df1/astest-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-15 16:43:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tusharsadhwani",
    "github_project": "astest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "astest"
}
        
Elapsed time: 0.82868s