From 1e48e99597bf9f0cc0219ab900f8ea140db4fea9 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Mon, 3 May 2021 18:47:33 +0900 Subject: [PATCH] Resolves: #1956213 CI for python-pycotap --- python-pycotap.spec | 5 ++++- tests/tests.py | 53 +++++++++++++++++++++++++++++++++++++++++++++ tests/tests.yml | 13 +++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 tests/tests.py create mode 100644 tests/tests.yml diff --git a/python-pycotap.spec b/python-pycotap.spec index eb61746..b8e0382 100644 --- a/python-pycotap.spec +++ b/python-pycotap.spec @@ -3,7 +3,7 @@ Name: python-%{pypi_name} Version: 1.1.0 -Release: 9%{?dist} +Release: 10%{?dist} Summary: A tiny test runner that outputs TAP results to standard output License: MIT @@ -49,6 +49,9 @@ find %{buildroot}/%{python3_sitelib} -name '*.py' | xargs sed -i '/^#!/d' %{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info %changelog +* Sat May 01 2021 Takao Fujiwara - 1.1.0-10 +- Enable CI. Related: rhbz#1956213 + * Fri Apr 16 2021 Mohan Boddu - 1.1.0-9 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 diff --git a/tests/tests.py b/tests/tests.py new file mode 100755 index 0000000..8c08d32 --- /dev/null +++ b/tests/tests.py @@ -0,0 +1,53 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from __future__ import print_function + +import sys +import unittest + +# Need to flush the output against Gtk.main() +def printflush(sentence): + try: + print(sentence, flush=True) + except IOError: + pass + +def printerr(sentence): + try: + print(sentence, flush=True, file=sys.stderr) + except IOError: + pass + +from pycotap import TAPTestRunner +from pycotap import LogMode +printflush('## Load pycotap') + + +class AnthyTest(unittest.TestCase): + __test_index = 0 + + @classmethod + def setUpClass(cls): + printflush('## setUpclass done') + cls.__test_index += 1 + + def setUp(self): + self.__test_index += 1 + printflush('## setUp done') + + def test_case1(self): + if self.__test_index != 2: + with self.subTest(i = self.__test_index): + self.fail('setUp does not run: ' + error.message) + printflush('## Test done %d' % self.__test_index) + + +def main(): + loader = unittest.TestLoader() + # Log should be in stderr instead of StringIO + runner = TAPTestRunner(test_output_log=LogMode.LogToError) + unittest.main(testRunner=runner, testLoader=loader) + +if __name__ == '__main__': + main() diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..22f5154 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,13 @@ +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-basic + #- role: standard-test-beakerlib + required_packages: + - python3-pycotap + tests: + - smoke1: + dir: . + run: ./tests.py +