Esempio n. 1
0
    def test_venv_docutils08_readme(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        fold = os.path.dirname(os.path.abspath(__file__))
        readme = os.path.join(fold, "..", "..", "README.rst")
        assert os.path.exists(readme)
        with open(readme, "r", encoding="utf8") as f:
            content = f.read()

        temp = get_temp_folder(__file__, "temp_readme")

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        create_virtual_env(temp, fLOG=fLOG, packages=["docutils==0.8"])
        outfile = os.path.join(temp, "conv_readme.html")

        script = ["from docutils import core",
                  "import io",
                  'from docutils.readers.standalone import Reader',
                  'from docutils.parsers.rst import Parser',
                  'from docutils.parsers.rst.directives.images import Image',
                  'from docutils.parsers.rst.directives import _directives',
                  'from docutils.writers.html4css1 import Writer',
                  "from docutils.languages import _languages",
                  "from docutils.languages import en, fr",
                  "_languages['en'] = en",
                  "_languages['fr'] = fr",
                  "_directives['image'] = Image",
                  "with open('{0}', 'r', encoding='utf8') as g: s = g.read()".format(
                      readme.replace("\\", "\\\\")),
                  "settings_overrides = {'output_encoding': 'unicode', 'doctitle_xform': True, 'initial_header_level': 2, 'warning_stream': io.StringIO()}",
                  "parts = core.publish_parts(source=s, parser=Parser(), reader=Reader(), source_path=None, destination_path=None, writer=Writer(), settings_overrides=settings_overrides)",
                  "with open('{0}', 'w', encoding='utf8') as f: f.write(parts['whole'])".format(
                      outfile.replace("\\", "\\\\")),
                  ]

        file_script = os.path.join(temp, "testreadme.py")
        with open(file_script, "w") as f:
            f.write("\n".join(script))

        run_venv_script(temp, file_script, fLOG=fLOG, file=True)
        with open(outfile, "r", encoding="utf8") as h:
            content = h.read()

        if "System Message" in content:
            raise Exception(content)
Esempio n. 2
0
    def test_venv_docutils08_readme(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        fold = os.path.dirname(os.path.abspath(__file__))
        readme = os.path.join(fold, "..", "..", "README.rst")
        assert os.path.exists(readme)
        with open(readme, "r", encoding="utf8") as f:
            content = f.read()

        temp = get_temp_folder(__file__, "temp_readme")

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        create_virtual_env(temp, fLOG=fLOG, packages=["docutils==0.8"])
        outfile = os.path.join(temp, "conv_readme.html")

        script = [
            "from docutils import core",
            "import io",
            'from docutils.readers.standalone import Reader',
            'from docutils.parsers.rst import Parser',
            'from docutils.parsers.rst.directives.images import Image',
            'from docutils.parsers.rst.directives import _directives',
            'from docutils.writers.html4css1 import Writer',
            "from docutils.languages import _languages",
            "from docutils.languages import en, fr",
            "_languages['en'] = en",
            "_languages['fr'] = fr",
            "_directives['image'] = Image",
            "with open('{0}', 'r', encoding='utf8') as g: s = g.read()".format(
                readme.replace("\\", "\\\\")),
            "settings_overrides = {'output_encoding': 'unicode', 'doctitle_xform': True, 'initial_header_level': 2, 'warning_stream': io.StringIO()}",
            "parts = core.publish_parts(source=s, parser=Parser(), reader=Reader(), source_path=None, destination_path=None, writer=Writer(), settings_overrides=settings_overrides)",
            "with open('{0}', 'w', encoding='utf8') as f: f.write(parts['whole'])"
            .format(outfile.replace("\\", "\\\\")),
        ]

        file_script = os.path.join(temp, "testreadme.py")
        with open(file_script, "w") as f:
            f.write("\n".join(script))

        run_venv_script(temp, file_script, fLOG=fLOG, file=True)
        with open(outfile, "r", encoding="utf8") as h:
            content = h.read()

        if "System Message" in content:
            raise Exception(content)
Esempio n. 3
0
    def test_build_install(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        # module
        ModuleInstall("multi_key_dict",
                      "github",
                      "formiaczek",
                      custom=["build", "install"])

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        temp = get_temp_folder(__file__, "temp_build_install")

        create_virtual_env(temp, fLOG=fLOG)
        setup = os.path.normpath(
            os.path.join(temp, "..", "..", "..", "setup.py"))
        assert os.path.exists(setup)
        folder = os.path.split(setup)[0]
        cmd = "{0} install".format(setup)
        fLOG("CMD: " + cmd)
        cwd = os.getcwd()
        os.chdir(folder)
        try:
            run_venv_script(temp, cmd, fLOG=noLOG, is_cmd=True)
        except Exception as e:
            version = "1.1"
            g = os.path.join(temp, "Lib", "site-packages",
                             "pymyinstall-%s-py3.5.egg" % version,
                             "pymyinstall")
            if not os.path.exists(g):
                raise e
        os.chdir(cwd)

        fLOG("INSTALL: module")
        script = """from pymyinstall import ModuleInstall
                    m = ModuleInstall('multi_key_dict', 'github', 'formiaczek', custom=['build', 'install'])
                    m.download(temp_folder='{0}')
                    m.install(temp_folder='{0}')
                    """.replace("                    ",
                                "").format(temp.replace("\\",
                                                        "/")).strip(" \n\r")
        fLOG(script)
        run_venv_script(temp, script, fLOG=fLOG)
    def test_build_install(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        # module
        ModuleInstall("multi_key_dict", "github", "formiaczek",
                      custom=["build", "install"])

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        temp = get_temp_folder(__file__, "temp_build_install")

        create_virtual_env(temp, fLOG=fLOG)
        setup = os.path.normpath(os.path.join(
            temp, "..", "..", "..", "setup.py"))
        assert os.path.exists(setup)
        folder = os.path.split(setup)[0]
        cmd = "setup.py install".format(setup)
        fLOG("CMD: " + cmd)
        cwd = os.getcwd()
        os.chdir(folder)
        try:
            run_venv_script(temp, cmd, fLOG=noLOG, is_cmd=True)
        except Exception as e:
            version = "1.1"
            g = os.path.join(temp, "Lib", "site-packages",
                             "pymyinstall-%s-py3.5.egg" % version, "pymyinstall")
            if not os.path.exists(g):
                raise e
        os.chdir(cwd)

        fLOG("INSTALL: module")
        script = """from pymyinstall import ModuleInstall
                    m = ModuleInstall('multi_key_dict', 'github', 'formiaczek', custom=['build', 'install'])
                    m.download(temp_folder='{0}')
                    m.install(temp_folder='{0}')
                    """.replace("                    ", "").format(temp.replace("\\", "/")).strip(" \n\r")
        fLOG(script)
        run_venv_script(temp, script, fLOG=fLOG)
    def test_venv_install_deps(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        fold = os.path.dirname(os.path.abspath(__file__))
        src_ = os.path.normpath(os.path.abspath(
            os.path.join(fold, "..", "..", "src")))
        assert os.path.exists(src_)
        temp = get_temp_folder(__file__, "temp_venv_install_deps")

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        if sys.version_info[0] == 2:
            # using nose so previous test is true
            warnings.warn(
                "does not work well from a virtual environment (Python 2.7)")
            return

        out = create_virtual_env(temp, fLOG=fLOG)
        src_ = src_.replace("\\", "/")
        temp = temp.replace("\\", "/")

        script = ["import sys",
                  "sys.path.append('{0}')".format(src_),
                  "from pymyinstall.packaged import install_module_deps",
                  "install_module_deps('imbox', temp_folder='{0}', source='2')".format(
                      temp),
                  ]

        file_script = os.path.join(temp, "test_install_deps.py")
        with open(file_script, "w") as f:
            f.write("\n".join(script))

        out = run_venv_script(temp, file_script, fLOG=fLOG, file=True)
        if "installing module  six" not in out:
            raise Exception(out)
    def test_venv_install_deps(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        fold = os.path.dirname(os.path.abspath(__file__))
        src_ = os.path.normpath(
            os.path.abspath(os.path.join(fold, "..", "..", "src")))
        assert os.path.exists(src_)
        temp = get_temp_folder(__file__, "temp_venv_install_deps")

        if __name__ != "__main__":
            warnings.warn("does not work well from a virtual environment")
            return

        if sys.version_info[0] == 2:
            # using nose so previous test is true
            warnings.warn(
                "does not work well from a virtual environment (Python 2.7)")
            return

        out = create_virtual_env(temp, fLOG=fLOG)
        src_ = src_.replace("\\", "/")
        temp = temp.replace("\\", "/")

        script = [
            "import sys",
            "sys.path.append('{0}')".format(src_),
            "from pymyinstall.packaged import install_module_deps",
            "install_module_deps('imbox', temp_folder='{0}', source='2')".
            format(temp),
        ]

        file_script = os.path.join(temp, "test_install_deps.py")
        with open(file_script, "w") as f:
            f.write("\n".join(script))

        out = run_venv_script(temp, file_script, fLOG=fLOG, file=True)
        if "installing module  six" not in out:
            raise Exception(out)