| | |
| | | self.assertNotIn("stdout", kwargs) |
| | | self.assertNotIn("stderr", kwargs) |
| | | |
| | | def test_run_script_passes_extra_args(self): |
| | | completed = subprocess.CompletedProcess( |
| | | args=[sys.executable, "fake.py"], |
| | | returncode=0, |
| | | ) |
| | | |
| | | with patch.object(a_stock_manager.subprocess, "run", return_value=completed) as run: |
| | | result = a_stock_manager.run_script( |
| | | "fake.py", |
| | | "fake task", |
| | | args=["--n-stocks", "all"], |
| | | ) |
| | | |
| | | self.assertTrue(result) |
| | | self.assertEqual( |
| | | run.call_args.args[0], |
| | | [ |
| | | sys.executable, |
| | | str(a_stock_manager.scripts_dir / "fake.py"), |
| | | "--n-stocks", |
| | | "all", |
| | | ], |
| | | ) |
| | | |
| | | def test_prompt_stock_count_args_supports_all(self): |
| | | with patch("builtins.input", return_value="2"): |
| | | args, description = a_stock_manager.prompt_stock_count_args() |
| | | |
| | | self.assertEqual(args, ["--n-stocks", "all"]) |
| | | self.assertIn("全量", description) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | unittest.main() |