Changaco / python-libarchive-c

Python interface to libarchive
Other
70 stars 37 forks source link

Minor test issues under pypy #103

Closed bollwyvl closed 3 years ago

bollwyvl commented 3 years ago

Hello, thanks for this project!

We're trying to package (and test) this under pypy3 over at conda-forge and have found only one issue, a small assumption that __builtins__ will always support the get.

This gets it sorted:

--- tests/surrogateescape.py    2016-11-29 13:03:26.000000000 -0500
+++ tests/surrogateescape.py    2020-09-24 08:41:30.005515345 -0400
@@ -12,7 +12,11 @@
 import codecs

-chr = __builtins__.get('unichr', chr)
+try:
+    chr = __builtins__.get('unichr', chr)
+except:
+    # pypy's builtins don't support get
+    pass

 def surrogateescape(exc):

...and everything (apparently) runs fine on Linux! But then, we no longer package/test on pypy 2.7, so...

Also, on OSX, there is also some timing precision issues with the atime_ctime tests:

______________________ test_memory_atime_ctime[pax-float] ______________________

archfmt = 'pax', timefmt = <class 'float'>

    @pytest.mark.parametrize('archfmt,timefmt', [('zip', int), ('pax', float)])
    def test_memory_atime_ctime(archfmt, timefmt):
        # Collect information on what should be in the archive
        tree = treestat('libarchive', stat_dict)

        # Create an archive of our libarchive/ directory
        buf = bytes(bytearray(1000000))
        with memory_writer(buf, archfmt) as archive1:
            archive1.add_files('libarchive/')

        # Check the data
        with memory_reader(buf) as archive2:
>           check_atime_ctime(archive2, tree, timefmt=timefmt)

tests/test_atime_mtime_ctime.py:47: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

archive = <libarchive.read.ArchiveRead object at 0x00007ffe9e05abf0>
tree = {'libarchive': os.stat_result(st_mode=16877, st_ino=12895306636, st_dev=16777220, st_nlink=11, st_uid=501, st_gid=20, ...uid=501, st_gid=20, st_size=849, _integer_atime=1600951970, _integer_mtime=1600951950, _integer_ctime=1600951983), ...}
timefmt = <class 'float'>

    def check_atime_ctime(archive, tree, timefmt=int):
        tree2 = copy(tree)
        for entry in archive:
            epath = str(entry).rstrip('/')
            assert epath in tree2
            estat = tree2.pop(epath)
E             +1600951983.855818
E             -1600951983.0

tests/test_atime_mtime_ctime.py:21: AssertionError

Thanks again!