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

Provide a way to isolate tests within one document #47

Closed
adamtheturtle opened this issue Mar 19, 2023 · 10 comments
Closed

Provide a way to isolate tests within one document #47

adamtheturtle opened this issue Mar 19, 2023 · 10 comments

Comments

@adamtheturtle
Copy link
Contributor

I am trying to switch from doctest to code-block with Sybil.
One issue I'm hitting is that I would like to have multiple separated tests within one document.

manuel provides .. reset-globs.
Is there a workaround to allow similar functionality with Sybil?

@adamtheturtle
Copy link
Contributor Author

I'm using:

.. invisible-code-block: python

   # Reset test
   for i in list(globals().keys()):
    if not i.startswith('_'):
        exec('del ' + i)

but this seems quite hacky.
My ideal is probably something like the groups in https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html.

@cjw296
Copy link
Member

cjw296 commented Mar 20, 2023

Feels like Sybil should grow something :-)

Rather than hacking the above, why not add your own parser that does this?
https://sybil.readthedocs.io/en/latest/use.html#developing-your-own-parsers

@adamtheturtle
Copy link
Contributor Author

@cjw296 with no promises - added to my TODO list!

@adamtheturtle
Copy link
Contributor Author

(and, thank you for the very neat project!)

@cjw296
Copy link
Member

cjw296 commented Mar 23, 2023

@adamtheturtle - what Python version are you using?

@adamtheturtle
Copy link
Contributor Author

@cjw296 Python 3.11.2

@cjw296
Copy link
Member

cjw296 commented Mar 24, 2023

@adamtheturtle - and what version of pytest?

@adamtheturtle
Copy link
Contributor Author

@cjw296 pytest 7.2.2

@cjw296
Copy link
Member

cjw296 commented Mar 26, 2023

Implemented in 8012155

@cjw296 cjw296 closed this as completed Mar 26, 2023
@cjw296
Copy link
Member

cjw296 commented Mar 26, 2023

Released in https://pypi.org/project/sybil/5.0.0/

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