aroberge / easygui_qt

Inspired by easygui, designed for PyQt
BSD 3-Clause "New" or "Revised" License
59 stars 18 forks source link

tests under python 2.7 #11

Closed jeremygray closed 9 years ago

jeremygray commented 9 years ago

Automated tests would make it much easier to support both python 2.7 and 3.4, e.g., using https://travis-ci.org

I tried to get tests to run using python -m unittest discover from the command line, but had multiple issues.

  1. Fixed PIL not being able to import Image by:

    % sudo mkdir -p /opt/anaconda1anaconda2anaconda3/lib/ % sudo ln /Users/jgray/anaconda/lib/libtiff.5.dylib /opt/anaconda1anaconda2anaconda3/lib/libtiff.5.dylib

  2. See branch p2-tests-work-in-progress for tweaks needed to test_easygui_qt.py for it to be able to even run. These are just notes to share, not something to merge in this form.
  3. The windows that come up are always behind other windows for me, and I have to manually bring them to the foreground in order for pyautogui to be able to send key-presses, etc. (This is a problem for me during normal usage, not just tests.)
  4. And then tests still fail with AssertionErrors
aroberge commented 9 years ago

@jeremygray I certainly agree that automated tests would be easier. This is why I had started on them (as you found out) but have not kept them up as you found out (and was using an unusual shortcut to start Anaconda's Python version). I'm labelling this as an "enhancement" to keep it visible. I want to clean up some use of global variables and complete the configuration savings work (after which, I'll be able to smplify the with_app decorator substantially). Then, I will look into implementing a better way to run unittests.

jeremygray commented 9 years ago

Cool. I like pytest (some familiarity, not expert level). A plus is that it works well with travis-ci.org (free for open-source projects). I have not used unittest, nose, or others (?), but my impression is that pytest is more powerful. I don't know how they compare or to what extent the others are supported by continuous integration servers.

aroberge commented 9 years ago

I have done very little automated tests seriously (just a hobbyist - rarely used github before!) but have tried unittest, nose, doctest (did lots of experimental work with doctest https://code.google.com/p/crunchy/source/browse/#svn%2Ftrunk%2Fcrunchy%2Fsrc%2Ftests for example) and pytest once or twice.

The choice of framework is somewhat secondary - from what I remember, I'd be perfectly happy to use pytest. What I need to do is learn about PyQt4 QtTest instead of using pywinauto. A quick search suggests that http://johnnado.com/pyqt-qtest-example/ would be a good starting place.

And, since I'm doing this project first for fun and learning (having it be useful for others is a nice bonus), I'd prefer to experiment on my own first to figure out how to do tests [and then, have others like you possibly tell me that I do it wrong and show me a better way ! :-) ]

jeremygray commented 9 years ago

I am also just a hobbyist. I've never used pytest to test a GUI, and am quite interested to learn how to do that. I look forward to seeing what you come up with!

aroberge commented 9 years ago

I have asked on the PyQt mailing list and on stackoverflow and no one has been able to help me. Since it looks like it just will not happen, I am going to close this issue and update the docs to indicate that unit tests are unfortunately not performed.