Пример #1
0
 def run(command):
     old_dir = os.getcwd()
     old_argv = copy.deepcopy(sys.argv)
     try:
         # Change the path to the root path of the project.
         os.chdir(os.path.abspath(communicator.project.paths["root"]))
         components = command.split()
         if components[0] != "lasif":
             msg = "Invalid LASIF CLI command."
             raise Exception(msg)
         sys.argv = components
         # Greatly speed up some tests.
         with mock.patch("lasif.tools.Q_discrete.calculate_Q_model") as p:
             p.return_value = (np.array([1.6341, 1.0513, 1.5257]),
                               np.array([0.59496, 3.7119, 22.2171]))
             capsys.readouterr()
             try:
                 lasif_cli.main()
             except SystemExit:
                 pass
     except Exception as exc:
         raise exc
     finally:
         # Reset environment
         os.chdir(old_dir)
         sys.arv = old_argv
     return Output(*capsys.readouterr())
Пример #2
0
 def run(command):
     old_dir = os.getcwd()
     old_argv = copy.deepcopy(sys.argv)
     try:
         # Change the path to the root path of the project.
         os.chdir(os.path.abspath(communicator.project.paths["root"]))
         components = command.split()
         if components[0] != "lasif":
             msg = "Invalid LASIF CLI command."
             raise Exception(msg)
         sys.argv = components
         # Greatly speed up some tests.
         with mock.patch("lasif.tools.Q_discrete.calculate_Q_model") as p:
             p.return_value = (np.array([1.6341, 1.0513, 1.5257]),
                               np.array([0.59496, 3.7119, 22.2171]))
             capsys.readouterr()
             try:
                 lasif_cli.main()
             except SystemExit:
                 pass
     except Exception as exc:
         raise exc
     finally:
         # Reset environment
         os.chdir(old_dir)
         sys.arv = old_argv
     return Output(*capsys.readouterr())
Пример #3
0
 def run(command):
     old_dir = os.getcwd()
     old_argv = copy.deepcopy(sys.argv)
     try:
         # Change the path to the root path of the project.
         os.chdir(os.path.abspath(project.paths["root"]))
         components = command.split()
         if components[0] != "lasif":
             msg = "Invalid LASIF CLI command."
             raise Exception(msg)
         sys.argv = components
         capsys.readouterr()
         try:
             lasif_cli.main()
         except SystemExit:
             pass
     except Exception as exc:
         raise exc
     finally:
         # Reset environment
         os.chdir(old_dir)
         sys.arv = old_argv
     return Output(*capsys.readouterr())