Guidance on Testing an Extension
(too old to reply)
Stephen McDowell
2018-04-08 23:02:00 UTC

I’m getting a little turned around on what I should be using to test my extension, but my understanding from [1] and the linked issue [2] and resultant docs [3], that (as long as I’m willing to assume Sphinx>=1.6) I should be using the internal sphinx stuff.

I was able to get both @with_app from the sphinx-testing repo and @pytest.mark.sphinx to work on global function objects, but I think I want to be using make_app for my purpose. I can’t find where the @pytest.mark.sphinx actually comes from though (forgive me, I’m very new to pytest, and still a little turned around with marking vs fixtures).

I’m using meta classes to generate some test_* methods, and doing @pytest.mark.sphinx inside the __new__ method of the meta class results in invalid bindings. I can only get it to work on global functions, but I need to be able to create configuration values based off subclass definitions.

I’m trying to figure out how to use make_app (create one without mark / fixture decorators), but don’t understand the interface [4]. It’s yielding the make method, resulting in a generator. I’ve been looking at a lot of the example test cases that use make_app, but theirs are always parameters and they are somehow able to make_app(
) aka their make_app is callable.

I was trying to use this because the docs on make_app say not to explicitly instantiate a SphinxTestApp.

Any advice on how to actually use this method? Thanks for any advice / tips / steering in different directions! In the end, without decorators, I just want to be able to instantiate a SphinxTestApp and override / set some configuration values, e.g. as the very first line of a class method.


[1]: https://groups.google.com/forum/#!searchin/sphinx-dev/pytest$20extension%7Csort:date/sphinx-dev/8iiwt4Yr28E/yN16SesmAgAJ <https://groups.google.com/forum/#!searchin/sphinx-dev/pytest$20extension|sort:date/sphinx-dev/8iiwt4Yr28E/yN16SesmAgAJ>
[2]: https://github.com/sphinx-doc/sphinx/issues/3458 <https://github.com/sphinx-doc/sphinx/issues/3458>
[3]: http://www.sphinx-doc.org/en/stable/devguide.html#unit-testing <http://www.sphinx-doc.org/en/stable/devguide.html#unit-testing>
[4]: https://github.com/sphinx-doc/sphinx/blob/6030e7390df37f0e3cd25cdc1e56dbb95107c69d/sphinx/testing/fixtures.py#L143 <https://github.com/sphinx-doc/sphinx/blob/6030e7390df37f0e3cd25cdc1e56dbb95107c69d/sphinx/testing/fixtures.py#L143>
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive: