A new unit test pattern

11 views
Skip to first unread message

Edward K. Ream

unread,
Jul 3, 2023, 12:23:11 PM7/3/23
to leo-editor

I have been adding new unit tests for some (not all) new functions/methods in the big PR.


Some of these tests are more complicated than usual. For example, tests of g.findAnyUnl require that the @data unl-path-prefixes setting refers to actual files.


The details are a bit messy, so I defined two new helpers:


TestGlobals._patch_at_data_unl_path_prefixes and

LeoUnitTest._set_setting.


The first calls the second. These helpers are themselves a new pattern for me.


The second new pattern defines unit tests for the helpers: 


LeoUnitTest.test_set_setting and

TestGlobals.test_patch_at_data_unl_path_prefixes.


Summary


g.findAnyUnl assumes that @data unl-path-prefixes is functional. Setting up this condition is more complicated than usual.


One new helper helps simulate the @data unl-path-prefixes setting.


The other new helper helps the helper :-)


New unit tests test both helpers.


Edward

Edward K. Ream

unread,
Jul 3, 2023, 12:28:29 PM7/3/23
to leo-e...@googlegroups.com
On Mon, Jul 3, 2023 at 11:23 AM Edward K. Ream <edre...@gmail.com> wrote:

g.findAnyUnl assumes that @data unl-path-prefixes is functional. Setting up this condition is more complicated than usual.


One new helper helps simulate the @data unl-path-prefixes setting.


The other new helper helps the helper :-)


New unit tests test both helpers.


One more part of the pattern. Organizer nodes contain both the helpers and their unit tests. See the LeoUnitTest and TestGlobals classes in leoTest2.py and test_leoGlobals.py.

Edward
Reply all
Reply to author
Forward
0 new messages