File: test_versions.py

package info (click to toggle)
mozjs78 78.15.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 739,892 kB
  • sloc: javascript: 1,344,214; cpp: 1,215,708; python: 526,544; ansic: 433,835; xml: 118,736; sh: 26,176; asm: 16,664; makefile: 11,537; yacc: 4,486; perl: 2,564; ada: 1,681; lex: 1,414; pascal: 1,139; cs: 879; exp: 499; java: 164; ruby: 68; sql: 45; csh: 35; sed: 18; lisp: 2
file content (102 lines) | stat: -rw-r--r-- 2,250 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from __future__ import absolute_import

import mozunit
import pytest

from mozrelease.versions import MozillaVersion


ALL_VERSIONS = [  # Keep this sorted
    '3.0',
    '3.0.1',
    '3.0.2',
    '3.0.3',
    '3.0.4',
    '3.0.5',
    '3.0.6',
    '3.0.7',
    '3.0.8',
    '3.0.9',
    '3.0.10',
    '3.0.11',
    '3.0.12',
    '3.0.13',
    '3.0.14',
    '3.0.15',
    '3.0.16',
    '3.0.17',
    '3.0.18',
    '3.0.19',
    '3.1b1',
    '3.1b2',
    '3.1b3',
    '3.5b4',
    '3.5b99',
    '3.5rc1',
    '3.5rc2',
    '3.5rc3',
    '3.5',
    '3.5.1',
    '3.5.2',
    '3.5.3',
    '3.5.4',
    '3.5.5',
    '3.5.6',
    '3.5.7',
    '3.5.8',
    '3.5.9',
    '3.5.10',
    # ... Start skipping around...
    '4.0b9',
    '10.0.2esr',
    '10.0.3esr',
    '32.0',
    '49.0a1',
    '49.0a2',
    '59.0',
    '60.0',
    '60.0esr',
    '60.0.1esr',
    '60.1',
    '60.1esr',
    '61.0',
]


@pytest.fixture(scope='function',
                params=range(len(ALL_VERSIONS) - 1),
                ids=lambda x: "{}, {}".format(ALL_VERSIONS[x], ALL_VERSIONS[x+1]))
def comparable_versions(request):
    index = request.param
    return ALL_VERSIONS[index], ALL_VERSIONS[index + 1]


@pytest.mark.parametrize('version', ALL_VERSIONS)
def test_versions_parseable(version):
    """Test that we can parse previously shipped versions.

    We only test 3.0 and up, since we never generate updates against
    versions that old."""
    assert MozillaVersion(version) is not None


def test_versions_compare_less(comparable_versions):
    """Test that versions properly compare in order."""
    smaller_version, larger_version = comparable_versions
    assert MozillaVersion(smaller_version) < MozillaVersion(larger_version)


def test_versions_compare_greater(comparable_versions):
    """Test that versions properly compare in order."""
    smaller_version, larger_version = comparable_versions
    assert MozillaVersion(larger_version) > MozillaVersion(smaller_version)


@pytest.mark.parametrize('version', ALL_VERSIONS)
def test_versions_compare_equal(version):
    """Test that versions properly compare as equal through multiple passes."""
    assert MozillaVersion(version) == MozillaVersion(version)


if __name__ == '__main__':
    mozunit.main()