Spaces:
Sleeping
Sleeping
File size: 2,817 Bytes
8e9aba4 2a98f83 976f8d8 4726b4a 976f8d8 3555cfd 2a98f83 9b3be67 2a98f83 9b3be67 2a98f83 3555cfd 9b3be67 2a98f83 3555cfd 2a98f83 9b3be67 2a98f83 9b3be67 2a98f83 3555cfd 9b3be67 2a98f83 9b3be67 2a98f83 9dbc6d3 2a98f83 3fbca11 2a98f83 9b3be67 2a98f83 3555cfd ef66f4a 3555cfd ef66f4a 3555cfd ef66f4a 3555cfd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
import unittest
from textwrap import dedent
from click import testing as click_testing
def get_runtests():
# Lazy load to avoid circular imports.
from .._cli.main import pysr
class TestCli(unittest.TestCase):
# TODO: Include test for custom project here.
def setUp(self):
self.cli_runner = click_testing.CliRunner()
def test_help_on_all_commands(self):
expected = dedent(
"""
Usage: pysr [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
install DEPRECATED (dependencies are now installed at import).
test Run parts of the PySR test suite.
"""
)
result = self.cli_runner.invoke(pysr, ["--help"])
self.assertEqual(result.output.strip(), expected.strip())
self.assertEqual(result.exit_code, 0)
def test_help_on_install(self):
expected = dedent(
"""
Usage: pysr install [OPTIONS]
DEPRECATED (dependencies are now installed at import).
Options:
-p, --project TEXT
-q, --quiet Disable logging.
--precompile
--no-precompile
--help Show this message and exit.
"""
)
result = self.cli_runner.invoke(pysr, ["install", "--help"])
self.assertEqual(result.output.strip(), expected.strip())
self.assertEqual(result.exit_code, 0)
def test_help_on_test(self):
expected = dedent(
"""
Usage: pysr test [OPTIONS] TESTS
Run parts of the PySR test suite.
Choose from main, jax, torch, cli, dev, and startup. You can give multiple
tests, separated by commas.
Options:
-k TEXT Filter expressions to select specific tests.
--help Show this message and exit.
"""
)
result = self.cli_runner.invoke(pysr, ["test", "--help"])
self.assertEqual(result.output.strip(), expected.strip())
self.assertEqual(result.exit_code, 0)
def runtests(just_tests=False):
"""Run all tests in cliTest.py."""
tests = [TestCli]
if just_tests:
return tests
loader = unittest.TestLoader()
suite = unittest.TestSuite()
for test in tests:
suite.addTests(loader.loadTestsFromTestCase(test))
runner = unittest.TextTestRunner()
return runner.run(suite)
return runtests
|