Beispiel #1
0
    def test_htmlhelp(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context(
            {"file_tail": file_tail, "Database": Database, "text": 3})
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        assert "<p>extracts the first nbline of a file " in res
        res = mg.hhelp("-np -f rst file_tail")
        assert ":param      threshold:" in res
        res = mg.hhelp("-np -f rawhtml Database")
        assert "SQL file which can be empty or not," in res
        doc = docstring2html(Database.__init__, format="rawhtml")
        assert "it can also contain several files separated by" in doc
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        assert "it can also contain several files separated by" in res
        res = mg.hhelp("Database.__init__")
        assert res is not None
        res = mg.hhelp("-np -f text Database.__init__")
        assert "it can also contain several files separated by" in res
        assert "@param" in res
    def test_htmlhelp(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context({
            "file_tail": file_tail,
            "Database": Database,
            "text": 3
        })
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        assert "<p>extracts the first nbline of a file " in res
        res = mg.hhelp("-np -f rst file_tail")
        assert ":param      threshold:" in res
        res = mg.hhelp("-np -f rawhtml Database")
        assert "SQL file which can be empty or not," in res
        doc = docstring2html(Database.__init__, format="rawhtml")
        assert "it can also contain several files separated by" in doc
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        assert "it can also contain several files separated by" in res
        res = mg.hhelp("Database.__init__")
        assert res is not None
        res = mg.hhelp("-np -f text Database.__init__")
        assert "it can also contain several files separated by" in res
        assert "@param" in res
Beispiel #3
0
    def test_textdiff(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        from IPython.core.display import Javascript
        mg = MagicFile()
        mg.add_context(
            {"f1": "STRING1\nSTRING2", "f2": "STRING1\nSTRING3"})
        cmd = "f1 f2"
        res = mg.textdiff(cmd)
        assert isinstance(res, Javascript)
Beispiel #4
0
    def test_files_compress(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        this = os.path.abspath(__file__)
        temp = get_temp_folder(__file__, "temp_compress")
        dest = os.path.join(temp, "temp_this.zip")

        mg = MagicFile()
        cmd = "dest [this]"
        fLOG("**", cmd)
        assert not os.path.exists(dest)
        mg.add_context({"this": this, "dest": dest})
        res = mg.compress(cmd)
        fLOG(res)
        assert os.path.exists(dest)
        assert res == 1