예제 #1
0
    def set_up(self):
        """Set up your applications and the test environment."""
        self.path.project = self.path.engine.parent

        if self.path.state.exists():
            self.path.state.rmtree(ignore_errors=True)
        self.path.state.mkdir()

        for filename, text in self.preconditions.get("files", {}).items():
            filepath = self.path.state.joinpath(filename)
            if not filepath.dirname().exists():
                filepath.dirname().mkdir()
            filepath.write_text(text)

        self.python_package = hitchpython.PythonPackage(
            self.preconditions.get('python_version', '3.5.0')
        )
        self.python_package.build()

        self.pip = self.python_package.cmd.pip
        self.python = self.python_package.cmd.python

        # Install debugging packages
        with hitchtest.monitor([self.path.engine.joinpath("debugrequirements.txt")]) as changed:
            if changed:
                run(self.pip("install", "-r", "debugrequirements.txt").in_dir(self.path.engine))

        # Uninstall and reinstall
        run(self.pip("uninstall", "hitchtrigger", "-y").ignore_errors())
        run(self.pip("install", ".").in_dir(self.path.project))

        run(self.pip("install", "peewee=={0}".format(self.preconditions['peewee_version'])))
        run(self.pip("install", "humanize=={0}".format(self.preconditions['humanize_version'])))

        self.services = hitchserve.ServiceBundle(
            str(self.path.project),
            startup_timeout=8.0,
            shutdown_timeout=1.0
        )

        self.services['IPython'] = hitchpython.IPythonKernelService(self.python_package)

        self.services.startup(interactive=False)
        self.ipython_kernel_filename = self.services['IPython'].wait_and_get_ipykernel_filename()
        self.ipython_step_library = hitchpython.IPythonStepLibrary()
        self.ipython_step_library.startup_connection(self.ipython_kernel_filename)

        self.run_command = self.ipython_step_library.run
        self.assert_true = self.ipython_step_library.assert_true
        self.assert_exception = self.ipython_step_library.assert_exception
        self.shutdown_connection = self.ipython_step_library.shutdown_connection
        self.run_command("import os")
        self.run_command("os.chdir('{}')".format(self.path.state))

        for line in self.settings['always run']:
            self.run_command(line)
예제 #2
0
파일: key.py 프로젝트: hitchtest/hitchdoc
    def set_up(self):
        if self.path.state.exists():
            self.path.state.rmtree(ignore_errors=True)
        self.path.state.mkdir()

        for filename, text in self.preconditions.get("files", {}).items():
            filepath = self.path.state.joinpath(filename)
            if not filepath.dirname().exists():
                filepath.dirname().mkdir()
            filepath.write_text(str(text))

        for filename, text in self.preconditions.get("variables", {}).items():
            filepath = self.path.state.joinpath(filename)
            if not filepath.dirname().exists():
                filepath.dirname().mkdir()
            filepath.write_text(str(text))

        self.path.engine.joinpath("code_that_does_things.py").copy(self.path.state)

        self.python_package = hitchpython.PythonPackage(
            self.preconditions.get('python_version', self.preconditions['python version'])
        )
        self.python_package.build()

        self.pip = self.python_package.cmd.pip
        self.python = self.python_package.cmd.python

        with hitchtest.monitor([self.path.keypath.joinpath("debugrequirements.txt")]) as changed:
            if changed:
                self.pip("install", "-r", "debugrequirements.txt").in_dir(self.path.keypath).run()

        self.pip("uninstall", "hitchdoc", "-y").ignore_errors().run()
        self.pip("install", ".").in_dir(self.path.project).run()

        self.services = hitchserve.ServiceBundle(
            str(self.path.project),
            startup_timeout=8.0,
            shutdown_timeout=1.0
        )

        self.services['IPython'] = hitchpython.IPythonKernelService(self.python_package)

        self.services.startup(interactive=False)
        self.ipython_kernel_filename = self.services['IPython'].wait_and_get_ipykernel_filename()
        self.ipython_step_library = hitchpython.IPythonStepLibrary()
        self.ipython_step_library.startup_connection(self.ipython_kernel_filename)

        self.run("import os")
        self.run("from path import Path")
        self.run("os.chdir('{}')".format(self.path.state))
        self.run("from code_that_does_things import *")

        for var, value in self.preconditions.get("variables", {}).items():
            self.run("{0} = Path('{0}').bytes().decode('utf8')".format(var))
예제 #3
0
    def set_up(self):
        """Set up your applications and the test environment."""
        self.python_package = hitchpython.PythonPackage(
            self.preconditions.get('python_version', '3.5.0')
        )
        self.python_package.build()

        # Uninstall and reinstall
        call([self.python_package.pip, "install", "ipython==1.2.1", ], stdout=PIPE)
        call([self.python_package.pip, "install", "pyzmq", ], stdout=PIPE)
        call([self.python_package.pip, "install", "flake8", ], stdout=PIPE)
        call([self.python_package.pip, "uninstall", "dumbyaml", "-y"], stdout=PIPE)
        #chdir(PROJECT_DIRECTORY)
        #check_call([self.python_package.python, "setup.py", "install"], stdout=PIPE)
        
        run(Command([self.python_package.python, "setup.py", "install"]).in_dir(PROJECT_DIRECTORY))
        #print(Command([self.python_package.python, "setup.py", "install"]).arguments)


        self.services = hitchserve.ServiceBundle(
            PROJECT_DIRECTORY,
            startup_timeout=8.0,
            shutdown_timeout=1.0
        )
        
        self.services['IPython'] = hitchpython.IPythonKernelService(self.python_package)
        
        self.services.startup(interactive=False)
        self.ipython_kernel_filename = self.services['IPython'].wait_and_get_ipykernel_filename()
        self.ipython_step_library = hitchpython.IPythonStepLibrary()
        self.ipython_step_library.startup_connection(self.ipython_kernel_filename)
        
        self.run_command = self.ipython_step_library.run
        self.assert_true = self.ipython_step_library.assert_true
        self.assert_exception = self.ipython_step_library.assert_exception
        self.shutdown_connection = self.ipython_step_library.shutdown_connection
        self.run_command("import dumbyaml")
        self.run_command("import yaml")
예제 #4
0
파일: key.py 프로젝트: tobbez/strictyaml
    def set_up(self):
        """Set up your applications and the test environment."""
        self.doc = hitchdoc.Recorder(
            hitchdoc.HitchStory(self),
            self.path.gen.joinpath('storydb.sqlite'),
        )

        if self.path.gen.joinpath("state").exists():
            self.path.gen.joinpath("state").rmtree(ignore_errors=True)
        self.path.gen.joinpath("state").mkdir()
        self.path.state = self.path.gen.joinpath("state")

        for filename, text in self.preconditions.get("files", {}).items():
            filepath = self.path.state.joinpath(filename)
            if not filepath.dirname().exists():
                filepath.dirname().mkdir()
            filepath.write_text(text)

        self.python_package = hitchpython.PythonPackage(
            self.preconditions.get('python_version', '3.5.0'))
        self.python_package.build()

        self.pip = self.python_package.cmd.pip
        self.python = self.python_package.cmd.python

        # Install debugging packages
        with hitchtest.monitor(
            [self.path.key.joinpath("debugrequirements.txt")]) as changed:
            if changed:
                run(
                    self.pip("install", "-r",
                             "debugrequirements.txt").in_dir(self.path.key))

        # Uninstall and reinstall
        run(self.pip("uninstall", "strictyaml", "-y").ignore_errors())
        run(self.pip("install", ".").in_dir(self.path.project))
        run(
            self.pip(
                "install", "ruamel.yaml=={0}".format(
                    self.preconditions["ruamel version"])))

        self.services = hitchserve.ServiceBundle(str(self.path.project),
                                                 startup_timeout=8.0,
                                                 shutdown_timeout=1.0)

        self.services['IPython'] = hitchpython.IPythonKernelService(
            self.python_package)

        self.services.startup(interactive=False)
        self.ipython_kernel_filename = self.services[
            'IPython'].wait_and_get_ipykernel_filename()
        self.ipython_step_library = hitchpython.IPythonStepLibrary()
        self.ipython_step_library.startup_connection(
            self.ipython_kernel_filename)

        self.shutdown_connection = self.ipython_step_library.shutdown_connection
        self.ipython_step_library.run("import os")
        self.ipython_step_library.run("import sure")
        self.ipython_step_library.run("from path import Path")
        self.ipython_step_library.run("os.chdir('{}')".format(self.path.state))

        for filename, text in self.preconditions.get("files", {}).items():
            self.ipython_step_library.run(
                """{} = Path("{}").bytes().decode("utf8")""".format(
                    filename.replace(".yaml", ""), filename))
예제 #5
0
    def set_up(self):
        """Set up your applications and the test environment."""
        self.path.project = self.path.engine.parent

        if self.path.state.exists():
            self.path.state.rmtree(ignore_errors=True)
        self.path.state.mkdir()

        for script, text in self.preconditions.get("scripts", {}).items():
            script_file = self.path.state.joinpath(script)
            if not script_file.dirname().exists():
                script_file.dirname().mkdir()
            script_file.write_text(text)
            script_file.chmod("u+x")

        for script, text in self.preconditions.get("files", {}).items():
            script_file = self.path.state.joinpath(script)
            if not script_file.dirname().exists():
                script_file.dirname().mkdir()
            script_file.write_text(text)

        self.python_package = hitchpython.PythonPackage(
            self.preconditions.get('python_version', '3.5.0'))
        self.python_package.build()

        self.pip = self.python_package.cmd.pip
        self.python = self.python_package.cmd.python

        # Uninstall and reinstall
        run(self.pip("install", "flake8"))
        run(self.pip("install", "ipython==1.2.1").ignore_errors())
        run(self.pip("install", "pyzmq").ignore_errors())
        run(self.pip("uninstall", "commandlib", "-y").ignore_errors())
        run(self.pip("install", ".").in_dir(self.path.project))

        if "pexpect_version" in self.preconditions:
            run(
                self.pip(
                    "install", "pexpect=={0}".format(
                        self.preconditions['pexpect_version'])))

        self.services = hitchserve.ServiceBundle(str(self.path.project),
                                                 startup_timeout=8.0,
                                                 shutdown_timeout=1.0)

        self.services['IPython'] = hitchpython.IPythonKernelService(
            self.python_package)

        self.services.startup(interactive=False)
        self.ipython_kernel_filename = self.services[
            'IPython'].wait_and_get_ipykernel_filename()
        self.ipython_step_library = hitchpython.IPythonStepLibrary()
        self.ipython_step_library.startup_connection(
            self.ipython_kernel_filename)

        self.run_command = self.ipython_step_library.run
        self.assert_true = self.ipython_step_library.assert_true
        self.assert_exception = self.ipython_step_library.assert_exception
        self.shutdown_connection = self.ipython_step_library.shutdown_connection
        self.run_command("from commandlib import Command, run")
        self.run_command("import os")
        self.run_command("os.chdir('{}')".format(self.path.state))