config: reject minversion if it's a list instead of a single string

Fixes:

src/_pytest/config/__init__.py:1071: error: Argument 1 to "Version" has incompatible type "Union[str, List[str]]"; expected "str"  [arg-type]
This commit is contained in:
Ran Benita 2020-06-12 16:26:33 +03:00
parent 1cf9405075
commit a5ab7c19fb
1 changed files with 5 additions and 0 deletions

View File

@ -1067,6 +1067,11 @@ class Config:
# Imported lazily to improve start-up time. # Imported lazily to improve start-up time.
from packaging.version import Version from packaging.version import Version
if not isinstance(minver, str):
raise pytest.UsageError(
"%s: 'minversion' must be a single value" % self.inifile
)
if Version(minver) > Version(pytest.__version__): if Version(minver) > Version(pytest.__version__):
raise pytest.UsageError( raise pytest.UsageError(
"%s: 'minversion' requires pytest-%s, actual pytest-%s'" "%s: 'minversion' requires pytest-%s, actual pytest-%s'"