Take a look in the *leo-editor\leo\unittests* directory. For example, *test_gui.py* imports g. etc. Maybe that will be enough to get started.
On Tuesday, December 26, 2023 at 9:44:46 PM UTC-5 [email protected] wrote: > Hello, there, > > My intuitive thought is that there are two types of tests in Leo, > > > 1. Testing of common Python function script nodes, > > > 2. Tests that require a Leo context, such as g, c, p, etc. > > 2.1 Test with Leo already open, because there are already g, c, p > > 2.2 Testing without Leo open. It is no different from a normal python > program. e.g. 'python -m unittest' > > > For 1, if I have such a Leo script node, can I test it? > > > ``` > def add(a, b): > return a + b > > import unittest > class TestAddFunction(unittest.TestCase): > > def test_add(self): > self.assertEqual(add(1, 2), 3) > self.assertEqual(add(-1, 1), 0) > self.assertEqual(add(-1, -1), -2) > ``` > > > For 2, Is this possible for the case in 2.1? > > > I flipped through the posts in the forums and it looked like there should > be a 'test-' command, but I only had 'test-one' in my environment, nothing > else. `execute-pytest` command also not works(maybe I am doing something > wrong) > > > I failed to find anything in the documentation that made me start. Am I > doing something wrong? > > > > Thanks! > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/1ed02ad0-0ae8-4f6e-8d7f-266a2fc8e678n%40googlegroups.com.
