esptest.common.version module

class esptest.common.version.VersionLimit(version_limit='')[source]

Bases: object

Represent a set of supported versions as one or more ranges.

Supported string formats:

  • v1.0 means v1.0 to unlimited.

  • Patch or multi-part versions are supported, for example v1.0.1 and v1.0.0-v2.0.3.

  • v1.0-v2.0 means the closed range [v1.0, v2.0].

  • [v1.0-v2.0), (v1.0-v2.0], and (v1.0-v2.0) express open/closed boundaries; for example, (v3.0-v4.0] excludes v3.0 and v3.0.0, but includes v3.0.1.

  • (v1.0-) means versions greater than v1.0 to unlimited.

  • Use ; to combine multiple ranges, for example v1.0-v2.0; v4.0.

& returns the intersection, | returns the union, and remove() subtracts ranges.

Parameters:

version_limit (str)

VERSION_LIMIT_PATTERN = re.compile('^\\s*(?P<left>[\\[\\(])?\\s*(?P<min_version>v?\\d+(?:\\.\\d+)*)(?:\\s*-\\s*(?P<max_version>v?\\d+(?:\\.\\d+)*)?)?\\s*(?P<right>[\\]\\)])?\\s*$')
EMPTY_VERSION_LIMIT_STR = '<empty>'
add(other)[source]
Parameters:

other (str | VersionLimit)

Return type:

VersionLimit

is_any()[source]
Return type:

bool

is_empty()[source]
Return type:

bool

remove(other)[source]
Parameters:

other (str | VersionLimit)

Return type:

VersionLimit

contains(version)[source]
Parameters:

version (str | Version)

Return type:

bool

esptest.common.version.version_contains(version, excepted_ver)[source]

Return whether excepted_ver is contained in the version-limit string version.

version uses the same formats as VersionLimit. Raises ValueError if version cannot be parsed.

Parameters:
  • version (str)

  • excepted_ver (str)

Return type:

bool

esptest.common.version.version_intersect(left, right)[source]

Return the intersection of two version-limit strings as a normalized string.

Returns '<empty>' when the ranges do not overlap, or '' when the result matches all versions. Raises ValueError if either argument cannot be parsed.

Parameters:
Return type:

str

esptest.common.version.version_union(left, right)[source]

Return the union of two version-limit strings as a normalized string.

Overlapping or adjacent ranges are merged. Returns '' when the result matches all versions. Raises ValueError if either argument cannot be parsed.

Parameters:
Return type:

str