Ticket #387 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Make Cython modules work with doctest

Reported by: dagss Owned by: dagss
Priority: major Milestone: 0.12
Component: Code Generation Keywords:
Cc:

Description (last modified by dagss) (diff)

A new directive "autotestdict" (might default to True unless opposition appears on ML). When enabled, *and* a __test__ dictionary is not already present, one is created containing all functions and methods with docstrings in the file, so that they get picked up by doctest.

 http://thread.gmane.org/gmane.comp.python.cython.devel/7626

Change History

Changed 4 years ago by dagss

  • owner changed from somebody to dagss
  • status changed from new to assigned

Changed 4 years ago by dagss

  • status changed from assigned to closed
  • resolution set to fixed

Changed 4 years ago by dagss

  • status changed from closed to reopened
  • resolution fixed deleted

There's a problem with cdef functions getting picked up, reopening (it's not turned on by default so no problem).

Changed 4 years ago by dagss

  • status changed from reopened to closed
  • resolution set to fixed
  • description modified (diff)

OK this is done now. The directive is renamed to autotestdict.

Changed 4 years ago by dagss

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 0.12 to 0.12.1

A new approach is needed; not all slots in cdef classes are available from Python space.

The best solution is probably:

  1. Generate __linenumbers__ dict statically
  2. Insert code in module startup to build __test__ dynamically from dir() and __linenumbers__.

This is much easier to do once CythonUtilityCode? is merged, which makes it more suitable for 0.12.1.

It could be turned off by default until that can be done if this is too much of an issue.

This hack ( http://hg.cython.org/cython-devel/rev/48ab4c8c76d1) should at least get Sage to compile, I think, but it is not even complete with regards to slot names.

Changed 4 years ago by dagss

  • milestone changed from 0.12.1 to 0.12

I guess the issue of whether it should be default should be revisited before pushing the ticket to 0.12.1.

Changed 4 years ago by dagss

  • milestone changed from 0.12 to 0.12.1

The blacklist has seen some more work/modifications and should be rather safe. We rather quickly started to depend on this feature (both in our tests and in my personal project code) so this should probably be left on by default for 0.12. Moving to 0.12.1 to revisit the question of the best implementation.

Changed 3 years ago by dagss

  • summary changed from Make Cython modules work with doctest to Improve Cython __test__ dict implementation
  • milestone changed from 0.12.1 to wishlist

Changed 3 years ago by dagss

  • summary changed from Improve Cython __test__ dict implementation to Make Cython modules work with doctest
  • milestone changed from wishlist to 0.12

On second thought, I'm opening a new ticket for improvement so that this gets into release history...

Changed 3 years ago by dagss

  • status changed from reopened to closed
  • resolution set to fixed

Follow-up on #497

Note: See TracTickets for help on using tickets.