Parse args from file (#12085)

Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
This commit is contained in:
Levon Saldamli
2024-03-09 07:51:52 +01:00
committed by GitHub
parent 2ccc73be9a
commit 9033d4d3ff
7 changed files with 66 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
import dataclasses
import importlib.metadata
import os
from pathlib import Path
import subprocess
import sys
import types
@@ -541,6 +542,32 @@ class TestGeneralUsage:
res = pytester.runpytest(p)
res.assert_outcomes(passed=3)
# Warning ignore because of:
# https://github.com/python/cpython/issues/85308
# Can be removed once Python<3.12 support is dropped.
@pytest.mark.filterwarnings("ignore:'encoding' argument not specified")
def test_command_line_args_from_file(
self, pytester: Pytester, tmp_path: Path
) -> None:
pytester.makepyfile(
test_file="""
import pytest
class TestClass:
@pytest.mark.parametrize("a", ["x","y"])
def test_func(self, a):
pass
"""
)
tests = [
"test_file.py::TestClass::test_func[x]",
"test_file.py::TestClass::test_func[y]",
"-q",
]
args_file = pytester.maketxtfile(tests="\n".join(tests))
result = pytester.runpytest(f"@{args_file}")
result.assert_outcomes(failed=0, passed=2)
class TestInvocationVariants:
def test_earlyinit(self, pytester: Pytester) -> None: