-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtest_compatibility.py
More file actions
43 lines (38 loc) · 1.21 KB
/
test_compatibility.py
File metadata and controls
43 lines (38 loc) · 1.21 KB
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
"""
test_compatibility
~~~~~~~~~~~~~~~~~~
Tests for names that exist purely for compatibility purposes.
"""
import re
from os.path import abspath, join, dirname
import brotlicffi
def test_compatible_names():
"""
Encoder modes are also defined as individual top-level names with the same
names as in brotlimodule.cc from the library.
"""
assert brotlicffi.MODE_GENERIC is brotlicffi.BrotliEncoderMode.GENERIC
assert brotlicffi.MODE_TEXT is brotlicffi.BrotliEncoderMode.TEXT
assert brotlicffi.MODE_FONT is brotlicffi.BrotliEncoderMode.FONT
def test_brotli_version():
"""
Test that the __version__ starts with the
Brotli version that's compiled with.
"""
version_h = join(
dirname(dirname(abspath(__file__))), "libbrotli/c/common/version.h"
)
with open(version_h) as f:
brotli_versions = dict(
re.findall(
r"#define BROTLI_VERSION_(MAJOR|MINOR|PATCH) ([0-9]+)",
f.read()
)
)
assert brotlicffi.__version__.startswith(
"{}.{}.{}.".format(
brotli_versions["MAJOR"],
brotli_versions["MINOR"],
brotli_versions["PATCH"]
)
)