# 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": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "dosbox,test,tas",
"author": "Vladimir Chebotarev",
"author_email": "vladimir.chebotarev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e9/6f/97e0ea2ef180d8a7f7a5a79665802126b5167166727fec1040ed4b3a7b2d/testbox-1.0.3.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.3",
"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": "e96f97e0ea2ef180d8a7f7a5a79665802126b5167166727fec1040ed4b3a7b2d",
"md5": "4428997547425a119e9bb9ceb970963f",
"sha256": "0ee4ac6792559e4edc30bfdf2f7d0ad1b662c9391fc5edbdc6473b91beb6c8fe"
},
"downloads": -1,
"filename": "testbox-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "4428997547425a119e9bb9ceb970963f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4744,
"upload_time": "2024-03-13T17:26:51",
"upload_time_iso_8601": "2024-03-13T17:26:51.103926Z",
"url": "https://files.pythonhosted.org/packages/e9/6f/97e0ea2ef180d8a7f7a5a79665802126b5167166727fec1040ed4b3a7b2d/testbox-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-13 17:26:51",
"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"
}