Debian Codegraph @

pypy/module/_cffi_backend/test/test_file.py

raw symbols SCIP
1 import urllib2, py
2 import pytest
3
4 @pytest.mark.skip("cffi has moved onto v2.0, the PyPy backend is 1.18")
5 def test_same_file():
6 from pypy.module._cffi_backend import VERSION
7 # '_backend_test_c.py' is a copy of 'c/test_c.py' from the CFFI repo,
8 # with the header lines (up to '# _____') stripped.
9 url = 'https://raw.githubusercontent.com/python-cffi/cffi/main/src/c/test_c.py'
10 source = urllib2.urlopen(url).read()
11 #
12 dest = py.path.local(__file__).join('..', '_backend_test_c.py').read()
13 #
14 source = source[source.index('# _____________'):]
15 dest = dest[dest.index('# _____________'):]
16
17 # source is for upstream dev version, dest can be different
18 # source = source.replace("1.18.0.dev0", "1.18.0.dev0")
19 source = source.replace("pytest.skip", "skip")
20 # remove patch for issue 4937. Leave the starting #
21 pstart = dest.index("# XXX patch start") + 1
22 pend = dest.index("XXX patch end") + len("XXX patch end")
23 dest = dest[:pstart] + dest[pend:]
24 if source.strip() != dest.strip():
25 raise AssertionError(
26 "Update test/_backend_test_c.py by copying it from " +
27 url + " and killing the import lines at the start")
28
29 def test_metadata_version():
30 from pypy.module._cffi_backend import VERSION
31 line = "Version: %s\n" % VERSION
32 metadatafile = py.path.local(__file__).join('..', '..', '..', '..', '..',
33 'lib_pypy',
34 'cffi-%s.dist-info' % VERSION,
35 'METADATA')
36 assert line in metadatafile.readlines()
37
38 def test_app_version():
39 from pypy.module import _cffi_backend
40 from lib_pypy import cffi
41 assert _cffi_backend.VERSION == cffi.__version__