File: test_version.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (53 lines) | stat: -rw-r--r-- 1,868 bytes parent folder | download | duplicates (2)
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
class AppTestVersion:
    def test_compiler(self):
        import sys
        assert ("MSC v." in sys.version or
                "GCC " in sys.version or
                "(untranslated)" in sys.version)

    def test_version_info(self):
        import sys
        assert str(sys.version_info).startswith('sys.version_info')

    def test_pypy_version_info(self):
        import sys
        assert str(sys.pypy_version_info).startswith('sys.pypy_version_info')

    def test_sys_implementation(self):
        import sys
        assert 'pypy_version_info' in str(sys.implementation)

    def test_implementation(self):
        import sys
        levels = {'alpha': 0xA, 'beta': 0xB, 'candidate': 0xC, 'final': 0xF}

        assert hasattr(sys.implementation, 'name')
        assert hasattr(sys.implementation, 'version')
        assert hasattr(sys.implementation, 'hexversion')
        assert hasattr(sys.implementation, 'cache_tag')

        version = sys.implementation.version
        assert version[:2] == (version.major, version.minor)

        hexversion = (version.major << 24 | version.minor << 16 |
                      version.micro << 8 | levels[version.releaselevel] << 4 |
                      version.serial << 0)
        assert sys.implementation.hexversion == hexversion

        # PEP 421 requires that .name be lower case.
        pypy = sys.implementation.name.lower()
        assert sys.implementation.name == pypy

    def test_git_version(self):
        import sys
        info = sys._git
        assert info[0] == "PyPy"


def test_get_version():
    from pypy.module.sys import version
    res = version._make_version_template(PYPY_VERSION=(2,5,0, "final", 1))
    assert "[PyPy 2.5.0" in res
    res = version._make_version_template(PYPY_VERSION=(2,6,3, "alpha", 5))
    assert "[PyPy 2.6.3-alpha5" in res
    assert res.endswith(' with %s]')