Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Aug 25, 2017
1 parent d9f5b98 commit 59b39b4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions _doc/notebooks/git_dataframes.ipynb
Expand Up @@ -184,7 +184,7 @@
], ],
"source": [ "source": [
"from gitpandas import Repository\n", "from gitpandas import Repository\n",
"tries = [\"../..\", \"../../..\"]\n", "tries = [\"../..\", \"../../..\", \"../../../..\"]\n",
"err = None\n", "err = None\n",
"for t in tries:\n", "for t in tries:\n",
" try:\n", " try:\n",
Expand All @@ -194,7 +194,7 @@
" err = e\n", " err = e\n",
" continue\n", " continue\n",
"if err is not None:\n", "if err is not None:\n",
" raise e" " raise err"
] ]
}, },
{ {
Expand Down
10 changes: 4 additions & 6 deletions _unittests/ut_helpgen/test_changes.py
Expand Up @@ -56,13 +56,11 @@ def modifiy_commit(nbch, date, author, comment):
generate_changes_repo(file, fold) generate_changes_repo(file, fold)
with open(file, "r", encoding="utf8") as f: with open(file, "r", encoding="utf8") as f:
content = f.read() content = f.read()
assert ".. plot::" in content self.assertIn(".. plot::", content)
content = content[ content = content[
content.find("List of recent changes:"):].split("\n") content.find("List of recent changes:"):]
ls = [len(_) for _ in content] self.assertTrue(len(content) > 0)
ml = max(ls) self.assertIn(":widths: auto", content)
total = [l for l in ls if ml - 100 <= l < ml]
assert len(ls) > 0 and len(total) == 0
else: else:
fLOG( fLOG(
"sorry, fixing a specific case on another project for accent problem") "sorry, fixing a specific case on another project for accent problem")
Expand Down
13 changes: 8 additions & 5 deletions _unittests/ut_helpgen/test_doxygen2rst.py
Expand Up @@ -81,11 +81,14 @@ def test_process_var_tag(self):
exp = """ exp = """
This is the documentation for this class. This is the documentation for this class.
+-----------+-----------------------------+ .. list-table::
| attribute | meaning | :widths: auto
+===========+=============================+ :header-rows: 1
| pa | an example of an attribute. |
+-----------+-----------------------------+ * - attribute
- meaning
* - pa
- an example of an attribute.
Inline :math:`x^2 + y + z`. Another equation to test: Inline :math:`x^2 + y + z`. Another equation to test:
Expand Down
16 changes: 8 additions & 8 deletions _unittests/ut_helpgen/test_utils_sphinxdocmain.py
Expand Up @@ -34,19 +34,19 @@ def test_sphinx_changes(self):
OutputPrint=__name__ == "__main__") OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0]) path = os.path.abspath(os.path.split(__file__)[0])
file = os.path.normpath(os.path.join(path, "..", "..")) file = os.path.normpath(os.path.join(path, "..", ".."))
assert os.path.exists(file) self.assertTrue(os.path.exists(file))
fLOG(file)


if sys.version_info[0] == 2: if sys.version_info[0] == 2:
return return


rst = generate_changes_repo(None, file) rst = generate_changes_repo(None, file)
fLOG(rst) # fLOG(rst[:5000])
assert len(rst) > 0 self.assertTrue(len(rst) > 0)
if "+-----------------------" not in rst: self.assertIn(".. list-table::", rst)
raise Exception( self.assertIn("* - #", rst)
"+----------------------- not in rst:\n" + self.assertIn("* - 2138", rst)
str(rst)) self.assertIn("- 2017-08-25", rst)
self.assertIn("- catch zip extension", rst)




if __name__ == "__main__": if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions src/pyquickhelper/pandashelper/tblformat.py
Expand Up @@ -92,7 +92,7 @@ def complete(cool):
s = "" s = ""
else: else:
s = typstr(s) s = typstr(s)
return s return (" " + s) if s else s
else: else:
i, s = cool i, s = cool
if s is None: if s is None:
Expand All @@ -108,10 +108,11 @@ def complete(cool):
if list_table: if list_table:


def format_on_row(row): def format_on_row(row):
one = "\n - ".join(map(complete, enumerate(row))) one = "\n -".join(map(complete, enumerate(row)))
return " * - " + one res = " * -" + one
return res


rows = [".. list-table:: {0}".format(title if title else "")] rows = [".. list-table:: {0}".format(title if title else "").strip()]
if column_size is None: if column_size is None:
rows.append(" :widths: auto") rows.append(" :widths: auto")
else: else:
Expand Down

0 comments on commit 59b39b4

Please sign in to comment.