Skip to main content

xayah

A lightweight testing tool with test report functionality

Table of contents

General info

Xayah is used to test and generate report for python applications. It is built to combine a testing tool with test report functionality. It allows testing modules and generate a test report in JSON format

test suite example:

from xayah import TestSuite, TestResult

def add(a, b):
  return a + b

@TestSuite.init
class TestAdd:
  def test_add(self):
     assert add(2, 3) == 5

# generating a test report
TestAdd.run_test_cases()
report = TestResult().create_test_result()

Installation

Xayah is available on PyPI:

python -m pip install xayah

Documentation

Xayah's documentation can be found in readthedocs: https://xayah.readthedocs.io/en/latest/

Features

  • adding title, description, severity levels, etc.
  • test parametrization
  • steps
  • skipping tests
  • generating test report

Usage

In order to generate report, the test class should be decorated with TestSuite.init method:

@TestSuite.init
class CheckTestCase:
    def test_method(self):
        assert 1 == 1

then all test method (with test prefix) of the tested class can be executed by calling run_test_cases method:

CheckTestCase.run_test_cases()

in order to created test result TestResult().create_test_result() method should be called:

result = TestResult().create_test_result()

then test result can be parsed in any format

Telegram_bot_example

Originally, xayah was built as a test report tool for telegram bots.

Here you can see the simple usage in telegram bot with selenium:

from aiogram import Bot, Dispatcher, executor, types
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from xayah import TestResult, TestSuite, TestCase

API_TOKEN = 'BOT TOKEN HERE'

# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)

@TestSuite.init
@TestSuite.title('Google main page')
class TestGoogle:
    @TestCase.title('page title is Google')
    def test_google(self):
        driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
        driver.get('https://www.google.com/')
        assert driver.title == 'Google', 'title is not google'


@dp.message_handler(commands=['test'])
async def test(message: types.Message):
    webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    TestGoogle.run_test_cases()
    result = TestResult().create_test_result()
    test_suite = result.get(TestGoogle.__name__)
    test_suite_title = test_suite.get('title')
    test_case = test_suite.get('test_cases')[0]
    test_case_title = test_case.get('title')
    test_case_status = test_case.get('status')
    text = f'<pre><b>{test_suite_title}:</b></pre>\n  <pre>{test_case_title} - {test_case_status}</pre>'
    await message.reply(text, parse_mode=types.ParseMode.HTML)
    
if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)

telegram bot's response:

Google main page:
  
page title is Google - passed

Future_work

Planned features:

  • Console application
  • Running xayah tests through console application
  • JSON generation
  • HTML page generation from the test report
  • PDF page generation from the test report
  • Integration with pytest
  • Making telegram bot integration easier

Release files for xayah 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xayah 0.0.8
File Size Uploaded
xayah-0.0.8.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xayah 0.0.8
File Interpreter ABI Platform
xayah-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / xayah-0.0.8.tar.gz

Download URL xayah-0.0.8.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8d3a26210f8ed7ab4c24c7f5da69dd6be0a9f21ed8e602eb1b82654314d9c84c
BLAKE2b-256 checksum
How to use checksums
db1933be33a64446ad7117bdb3fb8ded28158b28700f178355f6a32ba8332a0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / xayah-0.0.8-py3-none-any.whl

Download URL xayah-0.0.8-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b7fa36f3148e191fa90cc26da84ff6f9c504c3ccb8d8b65ea676c1a56f0b5b3
BLAKE2b-256 checksum
How to use checksums
fb55d2d346acb4f880f87816a794198e78048d9b017ba77656c877cdefca58a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page