From 93fc94363e6aeeb7bf45cdb57af3179e66933813 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 23 May 2024 10:44:01 -0400 Subject: Add test to Biz/Repl.py It's just a simple test, but it effectively tests that the `CustomRepl` can be instantiated for the ns and path. I also copied the unittest recipes I came up with in the other place I used Python tests so far: Biz/Llamacpp.py. Also, I'm beginning to see how a Biz/Cli.py module might work. Probably just a simple abstract base class with move, test, help, and tidy methods, pretty similar to the Haskell version. --- Biz/Llamacpp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Biz/Llamacpp.py') diff --git a/Biz/Llamacpp.py b/Biz/Llamacpp.py index 9a2ff86..66b57d8 100644 --- a/Biz/Llamacpp.py +++ b/Biz/Llamacpp.py @@ -19,14 +19,22 @@ class TestLlamaCpp(unittest.TestCase): def test_in_path(self) -> None: """Test that llama.cpp is in $PATH.""" - self.assertTrue("llama-cpp" in os.environ.get("PATH", "")) + self.assertIn("llama-cpp", os.environ.get("PATH", "")) + + +def test() -> None: + """Run this module's test suite.""" + suite = unittest.TestSuite() + suite.addTests( + unittest.defaultTestLoader.loadTestsFromTestCase(TestLlamaCpp), + ) + unittest.TextTestRunner().run(suite) def main() -> None: """Entrypoint.""" if sys.argv[1] == "test": - sys.argv.pop() - unittest.main() + test() else: sys.exit(0) -- cgit v1.2.3