Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures on 3.13 test_pathlib #413

Closed
stefanor opened this issue Sep 13, 2024 · 1 comment
Closed

Test failures on 3.13 test_pathlib #413

stefanor opened this issue Sep 13, 2024 · 1 comment

Comments

@stefanor
Copy link

I haven't dug into this at all, but I saw these test failures when test-building on Python 3.13:

https://docs.python.org/3.13/whatsnew/3.13.html

============================= test session starts ==============================
platform linux -- Python 3.13.0rc2, pytest-8.3.2, pluggy-1.5.0
rootdir: /<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build
configfile: pyproject.toml
plugins: typeguard-4.3.0
collected 511 items / 2 deselected / 509 selected

pybedtools/test/test_1.py .............................................. [  9%]
.......................x..x.x......                                      [ 15%]
pybedtools/test/test_cbedtools.py ...................................... [ 23%]
.                                                                        [ 23%]
pybedtools/test/test_contrib.py ..                                       [ 23%]
pybedtools/test/test_gzip_support.py ........                            [ 25%]
pybedtools/test/test_helpers.py ......                                   [ 26%]
pybedtools/test/test_issues.py ......................................... [ 34%]
.F                                                                       [ 35%]
pybedtools/test/test_iter.py ........................................... [ 43%]
........................................................................ [ 57%]
........................................................................ [ 71%]
........................................................................ [ 86%]
....................................................................     [ 99%]
pybedtools/test/test_pathlib.py FFF                                      [100%]

=================================== FAILURES ===================================
________________________________ test_issue_405 ________________________________

self = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))>
others = (PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'),)
kwargs = {}
other_beds = [<BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'))>]
other = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'))>
postmerge = True, force_truncate = False, stream_merge = False

    @_log_to_history
    def cat(self, *others, **kwargs):
        """
        Concatenate interval files together.
    
        Concatenates two BedTool objects (or an object and a file) and does an
        optional post-merge of the features.
    
        *postmerge=True* by default; use *postmerge=False* if you want to keep
        features separate.
    
        *force_truncate=False* by default; *force_truncate=True* to truncate
        all files to chrom, start, stop.
    
        When *force_truncate=False* and *postmerge=False*, the output will
        contain the smallest number of fields observed across all inputs. This
        maintains compatibility with BEDTools programs, which assume constant
        number of fields in all lines of a file.
    
        Other kwargs are sent to :meth:`BedTool.merge` (and assuming that
        *postmerge=True*).
    
        Example usage:
    
        >>> a = pybedtools.example_bedtool('a.bed')
        >>> b = pybedtools.example_bedtool('b.bed')
        >>> print(a.cat(b)) #doctest: +NORMALIZE_WHITESPACE
        chr1    1       500
        chr1    800     950
        <BLANKLINE>
        >>> print(a.cat(*[b,b],
        ...   postmerge=False)) #doctest: +NORMALIZE_WHITESPACE
        chr1    1       100     feature1        0       +
        chr1    100     200     feature2        0       +
        chr1    150     500     feature3        0       -
        chr1    900     950     feature4        0       +
        chr1    155     200     feature5        0       -
        chr1    800     901     feature6        0       +
        chr1    155     200     feature5        0       -
        chr1    800     901     feature6        0       +
        <BLANKLINE>
        """
        assert len(others) > 0, "You must specify at least one other bedfile!"
        other_beds = []
        for other in others:
            if isinstance(other, (str, Path)):
                other = BedTool(other)
            else:
                assert isinstance(
                    other, BedTool
                ), "Either filename or another BedTool instance required"
            other_beds.append(other)
    
        # postmerge and force_trucate don't get passed on to merge
        postmerge = kwargs.pop("postmerge", True)
        force_truncate = kwargs.pop("force_truncate", False)
        stream_merge = kwargs.get("stream", False)
        if stream_merge and postmerge:
            raise ValueError(
                "The post-merge step in the `cat()` method "
                "perfoms a sort, which uses stream=True.  Using "
                "stream=True for the merge as well will result in a "
                "deadlock!"
            )
    
        # if filetypes and field counts are the same, don't truncate
        if not force_truncate:
            try:
>               a_type = self.file_type

pybedtools/bedtool.py:3240: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))>

    @property
    def file_type(self):
        """
        Return the type of the current file.  One of ('bed','vcf','gff', 'bam',
        'sam', 'empty').
    
        >>> a = pybedtools.example_bedtool('a.bed')
        >>> print(a.file_type)
        bed
        """
        if not isinstance(self.fn, str):
>           raise ValueError(
                "Checking file_type not supported for "
                "non-file BedTools. Use .saveas() to "
                "save as a temp file first."
            )
E           ValueError: Checking file_type not supported for non-file BedTools. Use .saveas() to save as a temp file first.

pybedtools/bedtool.py:1106: ValueError

During handling of the above exception, another exception occurred:

    def test_issue_405():
        a = Path(pybedtools.example_filename('a.bed'))
        b = Path(pybedtools.example_filename('b.bed'))
        a = pybedtools.BedTool(a)
>       a.cat(b)

pybedtools/test/test_issues.py:921: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pybedtools/bedtool.py:907: in decorated
    result = method(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))>
others = (PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'),)
kwargs = {}
other_beds = [<BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'))>]
other = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/b.bed'))>
postmerge = True, force_truncate = False, stream_merge = False

    @_log_to_history
    def cat(self, *others, **kwargs):
        """
        Concatenate interval files together.
    
        Concatenates two BedTool objects (or an object and a file) and does an
        optional post-merge of the features.
    
        *postmerge=True* by default; use *postmerge=False* if you want to keep
        features separate.
    
        *force_truncate=False* by default; *force_truncate=True* to truncate
        all files to chrom, start, stop.
    
        When *force_truncate=False* and *postmerge=False*, the output will
        contain the smallest number of fields observed across all inputs. This
        maintains compatibility with BEDTools programs, which assume constant
        number of fields in all lines of a file.
    
        Other kwargs are sent to :meth:`BedTool.merge` (and assuming that
        *postmerge=True*).
    
        Example usage:
    
        >>> a = pybedtools.example_bedtool('a.bed')
        >>> b = pybedtools.example_bedtool('b.bed')
        >>> print(a.cat(b)) #doctest: +NORMALIZE_WHITESPACE
        chr1    1       500
        chr1    800     950
        <BLANKLINE>
        >>> print(a.cat(*[b,b],
        ...   postmerge=False)) #doctest: +NORMALIZE_WHITESPACE
        chr1    1       100     feature1        0       +
        chr1    100     200     feature2        0       +
        chr1    150     500     feature3        0       -
        chr1    900     950     feature4        0       +
        chr1    155     200     feature5        0       -
        chr1    800     901     feature6        0       +
        chr1    155     200     feature5        0       -
        chr1    800     901     feature6        0       +
        <BLANKLINE>
        """
        assert len(others) > 0, "You must specify at least one other bedfile!"
        other_beds = []
        for other in others:
            if isinstance(other, (str, Path)):
                other = BedTool(other)
            else:
                assert isinstance(
                    other, BedTool
                ), "Either filename or another BedTool instance required"
            other_beds.append(other)
    
        # postmerge and force_trucate don't get passed on to merge
        postmerge = kwargs.pop("postmerge", True)
        force_truncate = kwargs.pop("force_truncate", False)
        stream_merge = kwargs.get("stream", False)
        if stream_merge and postmerge:
            raise ValueError(
                "The post-merge step in the `cat()` method "
                "perfoms a sort, which uses stream=True.  Using "
                "stream=True for the merge as well will result in a "
                "deadlock!"
            )
    
        # if filetypes and field counts are the same, don't truncate
        if not force_truncate:
            try:
                a_type = self.file_type
    
                files = [self] + other_beds
                filetypes = set(
                    [self.file_type] + [i.file_type for i in other_beds]
                ).difference(["empty"])
                field_nums = (
                    set([self.field_count()] + [i.field_count() for i in other_beds])
                    .difference([None])
                    .difference([0])
                )
                same_field_num = len(field_nums) == 1
                same_type = len(set(filetypes)) == 1
            except ValueError:
>               raise ValueError(
                    "Can't check filetype or field count -- "
                    "is one of the files you're merging a 'streaming' "
                    "BedTool?  If so, use .saveas() to save to file first"
                )
E               ValueError: Can't check filetype or field count -- is one of the files you're merging a 'streaming' BedTool?  If so, use .saveas() to save to file first

pybedtools/bedtool.py:3254: ValueError

    def test_pathlib_base():
        file = "a.bed"
        fn = os.path.join(pybedtools.filenames.data_dir(), file)
        path = pathlib.PurePath(fn)
>       assert pybedtools.BedTool(path).fn == fn
E       AssertionError: assert PurePosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed') == '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'
E        +  where PurePosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed') = <BedTool(PurePosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))>.fn
E        +    where <BedTool(PurePosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))> = <class 'pybedtools.bedtool.BedTool'>(PurePosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))
E        +      where <class 'pybedtools.bedtool.BedTool'> = pybedtools.BedTool

pybedtools/test/test_pathlib.py:12: AssertionError
_____________________________ test_pathlib_derived _____________________________

    def test_pathlib_derived():
        file = "a.bed"
        fn = os.path.join(pybedtools.filenames.data_dir(), file)
        path = pathlib.Path(fn)
>       assert pybedtools.BedTool(path).fn == fn
E       AssertionError: assert PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed') == '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'
E        +  where PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed') = <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))>.fn
E        +    where <BedTool(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))> = <class 'pybedtools.bedtool.BedTool'>(PosixPath('/<<PKGBUILDDIR>>/.pybuild/cpython3_3.13_pybedtools/build/pybedtools/test/data/a.bed'))
E        +      where <class 'pybedtools.bedtool.BedTool'> = pybedtools.BedTool

pybedtools/test/test_pathlib.py:19: AssertionError
________________________ test_pathlib_nonexistent_file _________________________

    def test_pathlib_nonexistent_file():
        fn = os.path.join(pybedtools.filenames.data_dir(), "this_file_is_missing")
        path = pathlib.Path(fn)
>       with pytest.raises(FileNotFoundError):
E       Failed: DID NOT RAISE <class 'FileNotFoundError'>

pybedtools/test/test_pathlib.py:26: Failed
=========================== short test summary info ============================
FAILED pybedtools/test/test_issues.py::test_issue_405 - ValueError: Can't che...
FAILED pybedtools/test/test_pathlib.py::test_pathlib_base - AssertionError: a...
FAILED pybedtools/test/test_pathlib.py::test_pathlib_derived - AssertionError...
FAILED pybedtools/test/test_pathlib.py::test_pathlib_nonexistent_file - Faile...
=========== 4 failed, 502 passed, 2 deselected, 3 xfailed in 18.82s ============
@daler
Copy link
Owner

daler commented Nov 5, 2024

Thanks, fixed in #416. Turns out this was due to legacy support for Python 3.4 which we don't need any more!

@daler daler closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants