File: version_test.py

package info (click to toggle)
pygame 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 42,624 kB
  • sloc: ansic: 66,926; python: 48,742; javascript: 1,153; objc: 224; sh: 121; makefile: 59; cpp: 25
file content (48 lines) | stat: -rw-r--r-- 1,536 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
import os
import unittest


pg_header = os.path.join("src_c", "include", "_pygame.h")


class VersionTest(unittest.TestCase):
    @unittest.skipIf(
        not os.path.isfile(pg_header), "Skipping because we cannot find _pygame.h"
    )
    def test_pg_version_consistency(self):
        from pygame import version

        pgh_major = -1
        pgh_minor = -1
        pgh_patch = -1
        import re

        major_exp_search = re.compile(r"define\s+PG_MAJOR_VERSION\s+([0-9]+)").search
        minor_exp_search = re.compile(r"define\s+PG_MINOR_VERSION\s+([0-9]+)").search
        patch_exp_search = re.compile(r"define\s+PG_PATCH_VERSION\s+([0-9]+)").search
        with open(pg_header) as f:
            for line in f:
                if pgh_major == -1:
                    m = major_exp_search(line)
                    if m:
                        pgh_major = int(m.group(1))
                if pgh_minor == -1:
                    m = minor_exp_search(line)
                    if m:
                        pgh_minor = int(m.group(1))
                if pgh_patch == -1:
                    m = patch_exp_search(line)
                    if m:
                        pgh_patch = int(m.group(1))
        self.assertEqual(pgh_major, version.vernum[0])
        self.assertEqual(pgh_minor, version.vernum[1])
        self.assertEqual(pgh_patch, version.vernum[2])

    def test_sdl_version(self):
        from pygame import version

        self.assertEqual(len(version.SDL), 3)


if __name__ == "__main__":
    unittest.main()