WilliamBChf commited on
Commit
92ac433
1 Parent(s): 82f5f4d

Added tests to pipeline

Browse files
pysr/test/__init__.py CHANGED
@@ -2,3 +2,4 @@ from .test import runtests
2
  from .test_env import runtests as runtests_env
3
  from .test_jax import runtests as runtests_jax
4
  from .test_torch import runtests as runtests_torch
 
 
2
  from .test_env import runtests as runtests_env
3
  from .test_jax import runtests as runtests_jax
4
  from .test_torch import runtests as runtests_torch
5
+ from .cliTest import runtests as runtests_cli
pysr/test/__main__.py CHANGED
@@ -11,7 +11,7 @@ if __name__ == "__main__":
11
  parser.add_argument(
12
  "test",
13
  nargs="*",
14
- help="Test to run. One or more of 'main', 'env', 'jax', 'torch'.",
15
  )
16
 
17
  # Parse args:
@@ -25,7 +25,7 @@ if __name__ == "__main__":
25
 
26
  # Run tests:
27
  for test in tests:
28
- if test in {"main", "env", "jax", "torch"}:
29
  cur_dir = os.path.dirname(os.path.abspath(__file__))
30
  print(f"Running test from {cur_dir}")
31
  if test == "main":
@@ -36,6 +36,8 @@ if __name__ == "__main__":
36
  runtests_jax()
37
  elif test == "torch":
38
  runtests_torch()
 
 
39
  else:
40
  parser.print_help()
41
  raise SystemExit(1)
 
11
  parser.add_argument(
12
  "test",
13
  nargs="*",
14
+ help="Test to run. One or more of 'main', 'env', 'jax', 'torch', 'cli'.",
15
  )
16
 
17
  # Parse args:
 
25
 
26
  # Run tests:
27
  for test in tests:
28
+ if test in {"main", "env", "jax", "torch", "cli"}:
29
  cur_dir = os.path.dirname(os.path.abspath(__file__))
30
  print(f"Running test from {cur_dir}")
31
  if test == "main":
 
36
  runtests_jax()
37
  elif test == "torch":
38
  runtests_torch()
39
+ elif test == "cli":
40
+ runtests_cli()
41
  else:
42
  parser.print_help()
43
  raise SystemExit(1)
pysr/test/cliTest.py CHANGED
@@ -54,5 +54,10 @@ class TestCli(unittest.TestCase):
54
  self.assertEqual(expected, actual)
55
 
56
 
57
- if __name__ == '__main__':
58
- unittest.main()
 
 
 
 
 
 
54
  self.assertEqual(expected, actual)
55
 
56
 
57
+ def runtests():
58
+ """Run all tests in cliTest.py."""
59
+ loader = unittest.TestLoader()
60
+ suite = unittest.TestSuite()
61
+ suite.addTests(loader.loadTestsFromTestCase(TestCli))
62
+ runner = unittest.TextTestRunner()
63
+ return runner.run(suite)