##// END OF EJS Templates
typos...
luz.paz -
Show More
@@ -1,49 +1,49 b''
1 1 import sys
2 2 import os
3 3 from IPython.external.qt_for_kernel import QtCore, QtGui
4 4
5 5 # If we create a QApplication, keep a reference to it so that it doesn't get
6 6 # garbage collected.
7 7 _appref = None
8 8 _already_warned = False
9 9
10 10 def inputhook(context):
11 11 global _appref
12 12 app = QtCore.QCoreApplication.instance()
13 13 if not app:
14 14 if sys.platform == 'linux':
15 15 if not os.environ.get('DISPLAY') \
16 16 and not os.environ.get('WAYLAND_DISPLAY'):
17 17 import warnings
18 18 global _already_warned
19 19 if not _already_warned:
20 20 _already_warned = True
21 21 warnings.warn(
22 'The DISPLAY or WAYLAND_DISPLAY enviroment variable is '
23 'not set or empty and Qt5 requires this enviroment '
22 'The DISPLAY or WAYLAND_DISPLAY environment variable is '
23 'not set or empty and Qt5 requires this environment '
24 24 'variable. Deactivate Qt5 code.'
25 25 )
26 26 return
27 27 _appref = app = QtGui.QApplication([" "])
28 28 event_loop = QtCore.QEventLoop(app)
29 29
30 30 if sys.platform == 'win32':
31 31 # The QSocketNotifier method doesn't appear to work on Windows.
32 32 # Use polling instead.
33 33 timer = QtCore.QTimer()
34 34 timer.timeout.connect(event_loop.quit)
35 35 while not context.input_is_ready():
36 36 timer.start(50) # 50 ms
37 37 event_loop.exec_()
38 38 timer.stop()
39 39 else:
40 40 # On POSIX platforms, we can use a file descriptor to quit the event
41 41 # loop when there is input ready to read.
42 42 notifier = QtCore.QSocketNotifier(context.fileno(),
43 43 QtCore.QSocketNotifier.Read)
44 44 # connect the callback we care about before we turn it on
45 45 notifier.activated.connect(event_loop.exit)
46 46 notifier.setEnabled(True)
47 47 # only start the event loop we are not already flipped
48 48 if not context.input_is_ready():
49 49 event_loop.exec_()
@@ -1,46 +1,46 b''
1 1 """Some simple tests for the plugin while running scripts.
2 2 """
3 3 # Module imports
4 4 # Std lib
5 5 import inspect
6 6
7 7 # Our own
8 8
9 9 #-----------------------------------------------------------------------------
10 10 # Testing functions
11 11
12 12 def test_trivial():
13 13 """A trivial passing test."""
14 14 pass
15 15
16 16 def doctest_run():
17 17 """Test running a trivial script.
18 18
19 19 In [13]: run simplevars.py
20 20 x is: 1
21 21 """
22 22
23 23 def doctest_runvars():
24 """Test that variables defined in scripts get loaded correclty via %run.
24 """Test that variables defined in scripts get loaded correctly via %run.
25 25
26 26 In [13]: run simplevars.py
27 27 x is: 1
28 28
29 29 In [14]: x
30 30 Out[14]: 1
31 31 """
32 32
33 33 def doctest_ivars():
34 34 """Test that variables defined interactively are picked up.
35 35 In [5]: zz=1
36 36
37 37 In [6]: zz
38 38 Out[6]: 1
39 39 """
40 40
41 41 def doctest_refs():
42 42 """DocTest reference holding issues when running scripts.
43 43
44 44 In [32]: run show_refs.py
45 45 c referrers: [<... 'dict'>]
46 46 """
General Comments 0
You need to be logged in to leave comments. Login now