This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients JayKrish, Todd.Rovito, kbk, ncoghlan, philwebster, roger.serwy, terry.reedy
Date 2013-06-24.23:18:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372115933.33.0.106298034234.issue18189@psf.upfronthosting.co.za>
In-reply-to
Content
"test.support.requires" returns True if
"called from a context with __name__ = '__main__'" or
"'gui' in test.support.use_resources".

The first clause is never true for buildbots, so the presumption is that the test was invoked by a user with a gui screen. (Windoes has an extra test that is only relevant to buildbots.) See #18103 for more discussion.

Here is a minimal test_gui.py file. In what follows, I only note the print output and skip notices.

Running test_gui by itself:

F5 when file is in Idle editor; and
python -m idlelib.idle_test.test_gui
have identical output, as they should,
and print 'in gui', 'nogui', because test_gui is main.

python -m unittest idlelib.idle_test.test_gui
python -m unittest idlelib.idle_test.test_gui.FakeGuiTest
have identical output for this simple file
and print 'nogui', 'skipped=1', because test_gui is not main.

The first of these two lines is not needed; just omit 'unittest'.
The second means that we cannot pick out and run just a gui testcase from a file.

Running as part of suite:

F5 with test_idle loaded in editor window
python -m test -v test_idle
python -m test.test_idle
python -m unittest -v idlelib.idle_test
all print 'skipped', 'nogui', 'skipped=1'
(and otherwise similar output).
because verbosity is set either in the file or command line
and because main is not test_gui and 'gui' not in use_resources.

python -m test test_idle
prints only 'nogui', no skip notice
(because skips are ignored by non-verbose regrtest).

python -m test -ugui test_idle
prints 'in gui', 'nogui'
because regrtest sets use_resources to ['gui'].

python -m idlelib.idle_test does not run but would if there were a .__main__ similar to test.test_idle.

Attribute use_resources can be set by anyone, not just by regrtest.
In test_idle, after "if __name__ == '__main__':", add
    from test import support; support.use_resources = ['gui']
and
F5 with test_idle loaded in editor window
python -m test.test_idle
both print 'in gui', 'nogui'.

--
I added test_delegator.py and it skips when it should, but one must get verbose output to tell. (I do not see anything on the screen even when it does run.) Perhaps you mistook the absence of a failure report and the absence of a skip report to mean the absence of skips. It does not. Here is what I see.

C:\Users\Terry>python -m test test_idle
[1/1] test_idle
nogui
Warning -- os.environ was modified by test_idle
1 test altered the execution environment:
    test_idle

If I add '-ugui', the *only* visible difference is the added 'in gui' from my file. Prints are really useful for leaving a record.

With -v, the difference is
  skipped "Use of the 'gui' resource not enabled"
versus
  test_setdelegate (idlelib.idle_test.test_delegator.Test_delegator) ... ok
It appears that methods within a skipped testcase are not listed, whereas a skipped method within a not-skipped testcase is listed.

I believe your patch is working correctly as far is it goes, and that we should move forward.

The Delegator.py patch needs something like the use_resource line I added to test_idle in order for the gui test to run when Delegator.py is run. The line I gave will work; I am also thinking of a context manager.

As I said on idle-dev, I decided you were right to call your first TestCase 'PathBrowserTest' instead of 'Test_xxx', as I did at first. Having testcases end with 'Test' while methods begin with 'test' is less confusing. So let us make it 'DelegatorTest'.
History
Date User Action Args
2013-06-24 23:18:53terry.reedysetrecipients: + terry.reedy, kbk, ncoghlan, roger.serwy, Todd.Rovito, JayKrish, philwebster
2013-06-24 23:18:53terry.reedysetmessageid: <1372115933.33.0.106298034234.issue18189@psf.upfronthosting.co.za>
2013-06-24 23:18:53terry.reedylinkissue18189 messages
2013-06-24 23:18:53terry.reedycreate