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

Commit

Permalink
fix issues with unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jul 14, 2016
1 parent 0d8f9c6 commit 12859bf
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 45 deletions.
9 changes: 4 additions & 5 deletions _unittests/ut_funcwin/test_make_window2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ def test_file_binary(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")

if __name__ == "__main__":
functions = {"test_regular_expression": test_regular_expression,
"test_edit_distance": file_grep,
"file_head": file_head}
main_loop_functions(functions, title="title: TestMakeWindow2")
functions = {"test_regular_expression": test_regular_expression,
"test_edit_distance": file_grep,
"file_head": file_head}
main_loop_functions(functions, title="title: TestMakeWindow2", mainloop=False)


if __name__ == "__main__":
Expand Down
83 changes: 46 additions & 37 deletions _unittests/ut_funcwin/test_windows_autopy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,58 @@ def test_open_window_params(self):
if sys.version_info[0] == 2:
return

import autopy3
import autopy3.key
import autopy3.mouse
import autopy3.screen
try:
import autopy3
import autopy3.key
import autopy3.mouse
import autopy3.screen
autop = True
except ImportError:
warnings.warn("autopy3 is not installed")
autop = False

temp = get_temp_folder(__file__, "temp_autopy3")
root = [None]

def f():
fLOG("size", autopy3.screen.get_size())
icon = autopy3.bitmap.Bitmap.open(
os.path.join(temp, "..", "data", "icon.png"))
img = os.path.join(temp, "screen.png")
screen = autopy3.bitmap.capture_screen()
pos = screen.find_bitmap(icon)
iter = 0
while not pos and iter < 3:
if iter > 1:
fLOG("iter", iter, pos)
time.sleep(1)
if autop:
fLOG("size", autopy3.screen.get_size())
icon = autopy3.bitmap.Bitmap.open(
os.path.join(temp, "..", "data", "icon.png"))
img = os.path.join(temp, "screen.png")
screen = autopy3.bitmap.capture_screen()
pos = screen.find_bitmap(icon)
iter += 1
if not pos:
warnings.warn("unable to find icon in the screen")
pos = (117, 108)
screen.save(img)
fLOG("pos=", pos)

# test
fLOG((1, 1), autopy3.screen.point_visible(
1, 1), autopy3.screen.get_size())
if not autopy3.screen.point_visible(1, 1):
warnings.warn("autopy3.screen.point_visible is False")

# closes the window
if False and autopy3.screen.point_visible(1, 1):
# does not seem to work (point not visible)
dend = (986 - 117, 116 - 108)
end = (dend[0] + pos[0], dend[1] + pos[1])
autopy3.mouse.move(end[0], end[1])
autopy3.mouse.click(button=autopy3.mouse.LEFT_BUTTON)
else:
root[0].event_generate("<Alt-F4>")
iter = 0
while not pos and iter < 3:
if iter > 1:
fLOG("iter", iter, pos)
time.sleep(1)
screen = autopy3.bitmap.capture_screen()
pos = screen.find_bitmap(icon)
iter += 1
if not pos:
warnings.warn("unable to find icon in the screen")
pos = (117, 108)
screen.save(img)
fLOG("pos=", pos)

# test
fLOG((1, 1), autopy3.screen.point_visible(
1, 1), autopy3.screen.get_size())
if not autopy3.screen.point_visible(1, 1):
warnings.warn("autopy3.screen.point_visible is False")

# closes the window
if False and autopy3.screen.point_visible(1, 1):
# does not seem to work (point not visible)
dend = (986 - 117, 116 - 108)
end = (dend[0] + pos[0], dend[1] + pos[1])
autopy3.mouse.move(end[0], end[1])
autopy3.mouse.click(button=autopy3.mouse.LEFT_BUTTON)

if not autop:
time.sleep(2)
root[0].event_generate("<Alt-F4>")

th = threading.Thread(target=f)
th.start()
Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_helpgen/test_utils_sphinxdoc_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def test_full_documentation(self):
os.path.join(temp, "index_method.rst"),
os.path.join(temp, "all_example.rst"),
os.path.join(temp, "all_example_otherpageofexamples.rst"),
os.path.join(temp, "all_FAQ.rst"),
os.path.join(
temp,
"all_example_pagewithanaccentinthetitle.rst"),
Expand Down
7 changes: 7 additions & 0 deletions crypt_map.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__pycache__\test_encryption_cli.cpython-34.pyc ["__pycache__\\test_encryption_cli.cpython-34.pyc", ["__pycache__/aec246a96cbfb8d83a7e4a997c8b5b10_d71475d58865530d1ceeb00c505f8eb8"], "2016-07-14 18:23:34"]
__pycache__\test_encryption_cli.cpython-35.pyc ["__pycache__\\test_encryption_cli.cpython-35.pyc", ["__pycache__/27df07db6dbae3cf4871d810f36b552a_d90ead2db6e6a66523151dee80a9f916"], "2016-07-14 18:23:34"]
crypt_map.txt ["crypt_map.txt", ["2000816c8abc53bdcb1f8392070e38a8_2c0997df4cecbf2e148dbbe67c1a2d93"], "2016-07-14 18:23:34"]
crypt_status.txt ["crypt_status.txt", ["f9f347241ffddb9ccc5429ffea141d64_aee2cf974c16577a014ec4b1254e4263"], "2016-07-14 18:23:34"]
temp_encrypt_file\__file__.enc ["temp_encrypt_file\\__file__.enc", ["temp_encrypt_file/b9b0f24c671b68734fc5b64e180add45_cc14860b1864a5253f798ebbc151e709"], "2016-07-14 18:23:34"]
temp_encrypt_file\__file__.py ["temp_encrypt_file\\__file__.py", ["temp_encrypt_file/73703c02a536cc59570a4dfa20658d05_7636e89062cd2e8f70ff95cddaaa125f"], "2016-07-14 18:23:34"]
test_encryption_cli.py ["test_encryption_cli.py", ["c5143417e5a39bda65d1440fa7907fb8_9ebe352452c47184670168451d696051"], "2016-07-14 18:23:34"]
7 changes: 7 additions & 0 deletions crypt_status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\__pycache__\test_encryption_cli.cpython-34.pyc 1730 2016-07-14 18:23:34.084088 2016-04-03 00:16:15.267669 70a02fb167d1a97d550b2b18b471c86c
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\__pycache__\test_encryption_cli.cpython-35.pyc 2511 2016-07-14 18:23:34.137972 2016-07-14 18:15:40.669280 c8ce3822c6cfe738dc35a780b5b97ee0
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\crypt_map.txt 757 2016-07-14 18:23:34.175616 2016-05-15 19:08:53.628095 e0f60594512eb7a7165984d3139f805b
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\crypt_status.txt 1199 2016-07-14 18:23:34.222503 2016-05-15 19:08:53.612458 3d6dc575cf84fdf1f7a96da90da0c386
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\temp_encrypt_file\__file__.enc 2600 2016-07-14 18:23:34.271403 2016-05-15 19:08:53.803819 9c3b97b6d118a4d44cd27fc199aba053
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\temp_encrypt_file\__file__.py 2571 2016-07-14 18:23:34.314676 2016-05-15 19:08:53.803819 6813b866d7eae9c5c58369a4275b2d16
C:\xadupre\__home_\_data\GitHub\pyquickhelper\_unittests\ut_cli\temp_encrypt\..\test_encryption_cli.py 2571 2016-07-14 18:23:34.355953 2016-07-14 18:00:36.276587 6813b866d7eae9c5c58369a4275b2d16
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ansi2html
ansiconv
argparse
autopep8
autopy3
brewer2mpl
cloud-sptheme
codecov
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/sphinxext/sphinx_faqref_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def process_faqrefs(app, doctree):
this is not done in the directive itself because it some transformations
must have already been run, e.g. substitutions
"""
process_blocrefs_generic(app, doctree, "faqref")
process_blocrefs_generic(app, doctree, "faqref", class_node=faqref_node)


class FaqRefList(BlocRefList):
Expand Down
2 changes: 2 additions & 0 deletions src/pyquickhelper/texthelper/texts_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'todomes': '(The <<%s>> is located in %s, line %d.)',
'mathmes': '(<<%s>> : %s, line %d)',
'brefmes': '(<<%s>> : %s, line %d)',
'faqmes': '(<<%s>> : %s, line %d)',
},
'fr': {"blogpost": "article",
"toc": "Contenu",
Expand Down Expand Up @@ -70,5 +71,6 @@
'todomes': '(<<%s>> : %s, ligne %d)',
'mathmes': '(<<%s>> : %s, ligne %d)',
'brefmes': '(<<%s>> : %s, ligne %d)',
'faqmes': '(<<%s>> : %s, ligne %d)',
}
}

0 comments on commit 12859bf

Please sign in to comment.