This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-02/tests-kivy.py

45 lines
1.3 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python
"""Custom tests runner script for tox and python3"""
2022-08-10 01:54:27 +02:00
import os
import random # noseq
2022-08-10 01:54:27 +02:00
import subprocess
import sys
import unittest
from time import sleep
def unittest_discover():
"""Explicit test suite creation"""
loader = unittest.defaultTestLoader
loader.sortTestMethodsUsing = lambda a, b: random.randint(-1, 1)
return loader.discover('src.bitmessagekivy.tests')
if __name__ == "__main__":
in_docker = os.path.exists("/.dockerenv")
if in_docker:
try:
2022-08-10 01:54:27 +02:00
os.mkdir("../out")
except FileExistsError: # noqa:F821
pass
2022-08-10 01:54:27 +02:00
ffmpeg = subprocess.Popen([ # pylint: disable=consider-using-with
"ffmpeg", "-y", "-nostdin", "-f", "x11grab", "-video_size", "720x1280",
"-v", "quiet", "-nostats",
2022-08-10 01:54:27 +02:00
"-draw_mouse", "0", "-i", os.environ['DISPLAY'],
"-codec:v", "libvpx-vp9", "-lossless", "1", "-r", "60",
"../out/test.webm"
])
sleep(2) # let ffmpeg start
result = unittest.TextTestRunner(verbosity=2).run(unittest_discover())
2022-09-12 11:58:53 +02:00
sleep(1)
if in_docker:
ffmpeg.terminate()
try:
ffmpeg.wait(10)
2022-08-10 01:54:27 +02:00
except subprocess.TimeoutExpired:
ffmpeg.kill()
sys.exit(not result.wasSuccessful())