Beispiel #1
0
    def test_previewCheck18(self):
        """Switching between different files should update the log
        window accordingly.
        """
        core.config()['CodeChat']['Enabled'] = True
        # First create a warning only test case,
        document1 = self.createFile('file1.py', '# `<>_')
        # then an error only case,
        document2 = self.createFile('file2.py', '# .. h::')
        # then an error free case. Wait for the HTML to be generated before
        # continuing, so that the next assertHtmlReady won't accidentally catch
        # the HTML ready generated here.
        with self._WaitForHtmlReady():
            document3 = self.createFile('file3.py', '# <>_')
        base.waitForSignal(lambda: None, self._widget().webView.page().mainFrame().loadFinished, 200)

        # switch to document 1
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document1))
        base.waitForSignal(lambda: None, self._widget().webView.page().mainFrame().loadFinished, 200)
        ps = self._widget().prgStatus
        self.assertIn('#FF9955', ps.styleSheet())
        self.assertIn('Error(s): 0, warning(s): 1', ps.text())
        # switch to document 2
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document2))
        base.waitForSignal(lambda: None, self._widget().webView.page().mainFrame().loadFinished, 200)
        self.assertIn('red', ps.styleSheet())
        self.assertIn('Error(s): 1, warning(s): 0', ps.text())
        # switch to document 3
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document3))
        base.waitForSignal(lambda: None, self._widget().webView.page().mainFrame().loadFinished, 200)
        self.assertEqual(self._widget().prgStatus.styleSheet(), 'QLabel {}')
        self.assertEqual(self._logText(), '')
Beispiel #2
0
    def test_previewCheck18(self):
        """Switching between different files should update the log
        window accordingly.
        """
        core.config()['CodeChat']['Enabled'] = True
        # First create a warning only test case,
        document1 = self.createFile('file1.py', '# `<>_')
        # then an error only case,
        document2 = self.createFile('file2.py', '# .. h::')
        # then an error free case. Wait for the HTML to be generated before
        # continuing, so that the next assertHtmlReady won't accidentally catch
        # the HTML ready generated here.
        with self._WaitForHtmlReady():
            document3 = self.createFile('file3.py', '# <>_')
        base.waitForSignal(lambda: None, self._widget().webEngineView.page().loadFinished, 200)

        # switch to document 1
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document1), numEmittedExpected=2)
        base.waitForSignal(lambda: None, self._widget().webEngineView.page().loadFinished, 200)
        ps = self._widget().prgStatus
        self.assertIn('#FF9955', ps.styleSheet())
        self.assertIn('Error(s): 0, warning(s): 1', ps.text())
        # switch to document 2
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document2), numEmittedExpected=2)
        base.waitForSignal(lambda: None, self._widget().webEngineView.page().loadFinished, 200)
        self.assertIn('red', ps.styleSheet())
        self.assertIn('Error(s): 1, warning(s): 0', ps.text())
        # switch to document 3
        self._assertHtmlReady(lambda: core.workspace().setCurrentDocument(document3), numEmittedExpected=2)
        base.waitForSignal(lambda: None, self._widget().webEngineView.page().loadFinished, 200)
        self.assertEqual(self._widget().prgStatus.styleSheet(), 'QLabel {}')
        self.assertEqual(self._logText(), '')
Beispiel #3
0
    def test_previewCheck18(self):
        """Switching between different files should update the log
        window accordingly.
        """
        core.config()['CodeChat']['Enabled'] = True
        # First create a warning only test case,
        document1 = self.createFile('file1.py', '# `<>_')
        # then an error only case,
        document2 = self.createFile('file2.py', '# .. h::')
        # then an error free case.
        document3 = self.createFile('file3.py', '# <>_')

        # switch to document 1
        self._assertHtmlReady(
            lambda: core.workspace().setCurrentDocument(document1))
        base.waitForSignal(
            lambda: None,
            self._widget().webView.page().mainFrame().loadFinished, 200)
        ps = self._widget().prgStatus
        self.assertIn('#FF9955', ps.styleSheet())
        self.assertIn('Error(s): 0, warning(s): 1', ps.text())
        # switch to document 2
        self._assertHtmlReady(
            lambda: core.workspace().setCurrentDocument(document2))
        base.waitForSignal(
            lambda: None,
            self._widget().webView.page().mainFrame().loadFinished, 200)
        self.assertIn('red', ps.styleSheet())
        self.assertIn('Error(s): 1, warning(s): 0', ps.text())
        # switch to document 3
        self._assertHtmlReady(
            lambda: core.workspace().setCurrentDocument(document3))
        base.waitForSignal(
            lambda: None,
            self._widget().webView.page().mainFrame().loadFinished, 200)
        self.assertEqual(self._widget().prgStatus.styleSheet(), 'QLabel {}')
        self.assertEqual(self._logText(), '')
Beispiel #4
0
 def test_2(self):
     t = QTimer()
     t.setInterval(100)
     t.setSingleShot(True)
     self.assertFalse(base.waitForSignal(t.start, t.timeout, 50))
Beispiel #5
0
 def test_11(self):
     ts = TestSignal()
     with self.assertRaises(AssertionError):
         base.waitForSignal(lambda: self.fail(), ts.testSignal, 100)
Beispiel #6
0
 def test_11(self):
     ts = TestSignal()
     self.assertTrue(base.waitForSignal(lambda: ts.testSignalArgs.emit('hello', 3, 3.14),
                                        ts.testSignalArgs, 100, ('hello', 3, 3.14)))
Beispiel #7
0
 def test_9(self):
     ts = TestSignal()
     self.assertFalse(base.waitForSignal(lambda: ts.testSignalArgs.emit('hello', 3, 3.14),
                                         ts.testSignalArgs, 100, (2,)))
Beispiel #8
0
 def test_11(self):
     ts = TestSignal()
     with self.assertRaises(AssertionError):
         base.PRINT_EXEC_TRACKBACK = False
         base.waitForSignal(lambda: self.fail(), ts.testSignal, 100)
Beispiel #9
0
 def test_5(self):
     ts = TestSignal()
     self.assertTrue(base.waitForSignal(lambda: ts.testSignal.emit(1),
                                        ts.testSignal, 100))
Beispiel #10
0
 def test_3(self):
     bt = BackgroundThread(50)
     # Run the assertion after the other thread starts.
     self.assertTrue(base.waitForSignal(bt.start, bt.done, 100))
     # Wait for the background thread to finish before leaving this test.
     bt.wait()
Beispiel #11
0
 def test_2(self):
     t = QTimer()
     t.setInterval(100)
     t.setSingleShot(True)
     self.assertFalse(base.waitForSignal(t.start, t.timeout, 50))
Beispiel #12
0
 def test_11(self):
     ts = TestSignal()
     with self.assertRaises(AssertionError):
         base.waitForSignal(lambda: self.fail(), ts.testSignal, 100)
Beispiel #13
0
 def test_11(self):
     ts = TestSignal()
     self.assertTrue(
         base.waitForSignal(
             lambda: ts.testSignalArgs.emit('hello', 3, 3.14),
             ts.testSignalArgs, 100, ('hello', 3, 3.14)))
Beispiel #14
0
 def test_9(self):
     ts = TestSignal()
     self.assertFalse(
         base.waitForSignal(
             lambda: ts.testSignalArgs.emit('hello', 3, 3.14),
             ts.testSignalArgs, 100, (2, )))
Beispiel #15
0
 def test_7(self):
     ts = TestSignal()
     self.assertFalse(
         base.waitForSignal(lambda: ts.testSignal.emit(1), ts.testSignal,
                            100, (2, )))
Beispiel #16
0
 def test_3(self):
     bt = BackgroundThread(50)
     # Run the assertion after the other thread starts.
     self.assertTrue(base.waitForSignal(bt.start, bt.done, 100))
     # Wait for the background thread to finish before leaving this test.
     bt.wait()
Beispiel #17
0
 def test_4(self):
     bt = BackgroundThread(100)
     self.assertFalse(base.waitForSignal(bt.start, bt.done, 50))
     # Wait for the background thread to finish before leaving this test.
     bt.wait()
Beispiel #18
0
 def test_4(self):
     bt = BackgroundThread(100)
     self.assertFalse(base.waitForSignal(bt.start, bt.done, 50))
     # Wait for the background thread to finish before leaving this test.
     bt.wait()
Beispiel #19
0
 def test_7(self):
     ts = TestSignal()
     self.assertFalse(base.waitForSignal(lambda: ts.testSignal.emit(1),
                                         ts.testSignal, 100, (2,)))
Beispiel #20
0
 def test_5(self):
     ts = TestSignal()
     self.assertTrue(
         base.waitForSignal(lambda: ts.testSignal.emit(1), ts.testSignal,
                            100))