testbox


Nametestbox JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/excitoon/testbox
SummaryTest/TAS framework for DOSBox
upload_time2024-11-25 03:21:44
maintainerNone
docs_urlNone
authorVladimir Chebotarev
requires_pythonNone
licenseMIT
keywords dosbox test tas
VCS
bugtrack_url
requirements pillow
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TestBox

Test/TAS framework for DOSBox.

Run:

```
docker-compose -f docker-compose.example.yml run test
```

Or:

```
docker-compose -f docker-compose.example.console.yml run test
```

Tested on Ubuntu 20.10.

## Example

As test application I used "demo" version of Soko-Ban by Spectrum HoloByte. Please notice that test application is only included as an example. It is unplayable after level 2.

Test scenario includes full walkthrough of level 1.

```python
import testbox

with testbox.TestBox(['SOKOBAN.EXE'], {'cpu': {'cycles': 'max'}}) as box:
    box.wait_image('images/graphics.png', timeout=1)
    box.send_keys('C\r') # CGA mode.

    box.wait_image('images/input.png', timeout=1)
    box.send_keys('K\r') # Input from keyboard.

    box.wait_image('images/door.png', timeout=5)
    box.send_keys('\r') # Enter door.

    box.wait_image('images/lobby.png', timeout=1)
    box.send_keys('\r') # Enter elevator.

    box.wait_image('images/menu.png', timeout=5)
    box.send_keys('TEST\r') # Enter player name.

    box.wait_image('images/start.png', timeout=1)
    box.send_keys('\r') # Select single player mode.

    box.wait_image('images/elevator.png', timeout=1)
    box.send_keys('1A') # Select first floor and accept.

    for step, keys in (
        ('one', '▴◂◂◂▴▴▴◂▴◂◂▾◂◂▾▾▾▸▸▸▸▸▸▸▸▸▸▸▸▸▾▸▴◂◂'),
        ('two', '◂◂◂◂◂◂◂▴▴▴◂▴◂◂▾▾▾▴▴◂◂▾▾▾▸▸▸▸▸▸▸▸▸▸▸▸▴▸▾◂▾▸▴◂'),
        ('three', '◂◂◂◂◂◂◂▴▴▴◂◂▴◂▾▾▾▴▴◂◂▾▾▾▸▸▸▸▸▸▸▸▸▸▸▸▾▸▴◂'),
        ('four', '◂◂◂◂◂◂◂▴▴▴◂◂▴▴▴◂▾▾▾▾▾▴▴◂◂▾▾▾▸▸▸▸▸▸▸▸▸▸▸▴▸▾◂▾▸▴'),
        ('five', '◂◂◂◂◂◂◂▴▴▴◂◂▴▴▴▸▾▾◂◂▾◂◂▾▾◂◂▾▸▸▸▸▸▸▸▸▸▸▸▸▸▸▸◂'),
        ('six', '◂◂◂◂◂◂◂▴▴▴◂◂▴◂▾▾▾▴▴◂◂▾▾▾▸▸▸▸▸▸▸▸▸▸▸▸'),
    ):
        # Checkpoint, skipping status bar.
        box.wait_image(f'images/step-{step}.png', bbox=(0, 0, 320, 191), timeout=3)

        for key in keys:
            box.send_keys(key)
            # Waiting move counter to update.
            box.wait_change(bbox=(75, 191, 110, 200), timeout=1)

    box.wait_image('images/victory.png', timeout=10) # Level 2.
```

![Test application](example/video.gif)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/excitoon/testbox",
    "name": "testbox",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "dosbox, test, tas",
    "author": "Vladimir Chebotarev",
    "author_email": "vladimir.chebotarev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/fb/57ea979768ee7efa880bda0ca26293eea7e377a1fd0be660182dbe1e1788/testbox-1.0.4.tar.gz",
    "platform": null,
    "description": "# TestBox\n\nTest/TAS framework for DOSBox.\n\nRun:\n\n```\ndocker-compose -f docker-compose.example.yml run test\n```\n\nOr:\n\n```\ndocker-compose -f docker-compose.example.console.yml run test\n```\n\nTested on Ubuntu 20.10.\n\n## Example\n\nAs test application I used \"demo\" version of Soko-Ban by Spectrum HoloByte. Please notice that test application is only included as an example. It is unplayable after level 2.\n\nTest scenario includes full walkthrough of level 1.\n\n```python\nimport testbox\n\nwith testbox.TestBox(['SOKOBAN.EXE'], {'cpu': {'cycles': 'max'}}) as box:\n    box.wait_image('images/graphics.png', timeout=1)\n    box.send_keys('C\\r') # CGA mode.\n\n    box.wait_image('images/input.png', timeout=1)\n    box.send_keys('K\\r') # Input from keyboard.\n\n    box.wait_image('images/door.png', timeout=5)\n    box.send_keys('\\r') # Enter door.\n\n    box.wait_image('images/lobby.png', timeout=1)\n    box.send_keys('\\r') # Enter elevator.\n\n    box.wait_image('images/menu.png', timeout=5)\n    box.send_keys('TEST\\r') # Enter player name.\n\n    box.wait_image('images/start.png', timeout=1)\n    box.send_keys('\\r') # Select single player mode.\n\n    box.wait_image('images/elevator.png', timeout=1)\n    box.send_keys('1A') # Select first floor and accept.\n\n    for step, keys in (\n        ('one', '\u25b4\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25b4\u25c2\u25c2\u25be\u25c2\u25c2\u25be\u25be\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25be\u25b8\u25b4\u25c2\u25c2'),\n        ('two', '\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25b4\u25c2\u25c2\u25be\u25be\u25be\u25b4\u25b4\u25c2\u25c2\u25be\u25be\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b4\u25b8\u25be\u25c2\u25be\u25b8\u25b4\u25c2'),\n        ('three', '\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25c2\u25b4\u25c2\u25be\u25be\u25be\u25b4\u25b4\u25c2\u25c2\u25be\u25be\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25be\u25b8\u25b4\u25c2'),\n        ('four', '\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25be\u25be\u25be\u25be\u25be\u25b4\u25b4\u25c2\u25c2\u25be\u25be\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b4\u25b8\u25be\u25c2\u25be\u25b8\u25b4'),\n        ('five', '\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25c2\u25b4\u25b4\u25b4\u25b8\u25be\u25be\u25c2\u25c2\u25be\u25c2\u25c2\u25be\u25be\u25c2\u25c2\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25c2'),\n        ('six', '\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25c2\u25b4\u25b4\u25b4\u25c2\u25c2\u25b4\u25c2\u25be\u25be\u25be\u25b4\u25b4\u25c2\u25c2\u25be\u25be\u25be\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8\u25b8'),\n    ):\n        # Checkpoint, skipping status bar.\n        box.wait_image(f'images/step-{step}.png', bbox=(0, 0, 320, 191), timeout=3)\n\n        for key in keys:\n            box.send_keys(key)\n            # Waiting move counter to update.\n            box.wait_change(bbox=(75, 191, 110, 200), timeout=1)\n\n    box.wait_image('images/victory.png', timeout=10) # Level 2.\n```\n\n![Test application](example/video.gif)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Test/TAS framework for DOSBox",
    "version": "1.0.4",
    "project_urls": {
        "Documentation": "https://github.com/excitoon/testbox/blob/master/README.md",
        "Homepage": "https://github.com/excitoon/testbox",
        "Source": "https://github.com/excitoon/testbox",
        "Tracker": "https://github.com/excitoon/testbox/issues"
    },
    "split_keywords": [
        "dosbox",
        " test",
        " tas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8cfb57ea979768ee7efa880bda0ca26293eea7e377a1fd0be660182dbe1e1788",
                "md5": "513043ec771d5504f41bed27d4775c0f",
                "sha256": "bfc979f0e0c949a0dca23bdf9e4f9a1b79d0677ee98fae16fce93502c6bcdb34"
            },
            "downloads": -1,
            "filename": "testbox-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "513043ec771d5504f41bed27d4775c0f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4942,
            "upload_time": "2024-11-25T03:21:44",
            "upload_time_iso_8601": "2024-11-25T03:21:44.113351Z",
            "url": "https://files.pythonhosted.org/packages/8c/fb/57ea979768ee7efa880bda0ca26293eea7e377a1fd0be660182dbe1e1788/testbox-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-25 03:21:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "excitoon",
    "github_project": "testbox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pillow",
            "specs": []
        }
    ],
    "lcname": "testbox"
}
        
Elapsed time: 2.26041s