1
0
Fork 0
terminaltables/tests/test_examples.py
Daniel Baumann 07735c967b
Merging upstream version 4.0.0 (Closes: #1095814).
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-12 15:00:49 +01:00

32 lines
702 B
Python

"""Test example scripts."""
import os
import subprocess
import sys
import pytest
from tests import PROJECT_ROOT
@pytest.mark.parametrize("filename", map("example{}.py".format, (1, 2, 3)))
def test(filename):
"""Test with subprocess.
:param str filename: Example script filename to run.
"""
command = [sys.executable, str(PROJECT_ROOT.join(filename))]
env = dict(os.environ, PYTHONIOENCODING="utf-8")
# Run.
proc = subprocess.Popen(
command, env=env, stderr=subprocess.STDOUT, stdout=subprocess.PIPE
)
output = proc.communicate()[0]
# Verify.
try:
assert proc.poll() == 0
except AssertionError:
print(output)
raise