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

# optional - !xx doesn't work #39493

Open
user202729 opened this issue Feb 11, 2025 · 0 comments
Open

# optional - !xx doesn't work #39493

user202729 opened this issue Feb 11, 2025 · 0 comments

Comments

@user202729
Copy link
Contributor

user202729 commented Feb 11, 2025

Assume you have a doc test of the form

sage: 2 # optional - !xx

and run sage -t --optional=xx a.py, the doc test is still run.

The problem is there are multiple places that populate the list…

First in doctest/control

                # We replace the 'optional' tag by all optional
                # packages for which the installed version matches the
                # latest available version (this implies in particular
                # that the package is actually installed).
                if 'optional' in options.optional:
                    options.optional.discard('optional')
                    from sage.misc.package import list_packages
                    for pkg in list_packages('optional', local=True).values():
                        if pkg.name in options.hide:
                            continue
                        # Skip features for which we have a more specific runtime feature test.
                        if pkg.name in ['bliss', 'coxeter3', 'mcqd', 'meataxe', 'sirocco', 'tdlib']:
                            continue
                        if pkg.is_installed() and pkg.installed_version == pkg.remote_version:
                            options.optional.add(pkg.name)

Second in doctest/parsing

                        for tag in optional_tags:
                            if tag not in self.optional_tags:
                                if tag.startswith('!'):
                                    if tag[1:] in available_software:
                                        extra.add(tag)
                                elif tag not in available_software:
                                    extra.add(tag)

In this case the xx is put in options.optional by the first block, then it goes to self.optional_tags, which triggers the check, but tag[1:] in available_software returns False. Here extra is the list of "extra conditions" for the doctest to be run.

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

1 participant