Skip test_ExampleApp

This commit is contained in:
Ogi Moore 2020-12-20 20:15:03 -08:00
parent 3cd9f9ff63
commit f4df660363
2 changed files with 43 additions and 47 deletions

View File

@ -49,7 +49,7 @@ jobs:
run: | run: |
pip install ${{ matrix.qt-lib }}${{ matrix.qt-version }} numpy${{ matrix.numpy-version }} scipy pyopengl h5py six matplotlib pip install ${{ matrix.qt-lib }}${{ matrix.qt-version }} numpy${{ matrix.numpy-version }} scipy pyopengl h5py six matplotlib
pip install . pip install .
pip install pytest pytest-cov coverage pytest-xdist pip install pytest pytest-cov coverage
- name: "Install Linux VirtualDisplay" - name: "Install Linux VirtualDisplay"
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: | run: |
@ -73,7 +73,6 @@ jobs:
- name: Run Tests - name: Run Tests
run: | run: |
pytest . -v \ pytest . -v \
-n 1 \
--junitxml=junit/test-results.xml \ --junitxml=junit/test-results.xml \
--cov pyqtgraph --cov-report=xml --cov-report=html --cov pyqtgraph --cov-report=xml --cov-report=html
shell: bash shell: bash

View File

@ -1,4 +1,6 @@
import keyword
import os import os
import re
import sys import sys
import subprocess import subprocess
import pyqtgraph as pg import pyqtgraph as pg
@ -104,7 +106,7 @@ examples = OrderedDict([
# based on https://github.com/art1415926535/PyQt5-syntax-highlighting # based on https://github.com/art1415926535/PyQt5-syntax-highlighting
QRegExp = QtCore.QRegExp QRegularExpression = QtCore.QRegularExpression
QFont = QtGui.QFont QFont = QtGui.QFont
QColor = QtGui.QColor QColor = QtGui.QColor
@ -208,31 +210,24 @@ class PythonHighlighter(QSyntaxHighlighter):
"""Syntax highlighter for the Python language. """Syntax highlighter for the Python language.
""" """
# Python keywords # Python keywords
keywords = [ keywords = keyword.kwlist
'and', 'assert', 'break', 'class', 'continue', 'def',
'del', 'elif', 'else', 'except', 'exec', 'finally',
'for', 'from', 'global', 'if', 'import', 'in',
'is', 'lambda', 'not', 'or', 'pass', 'print',
'raise', 'return', 'try', 'while', 'yield',
'None', 'True', 'False', 'async', 'await',
]
# Python operators # Python operators
operators = [ operators = [
'=', r'=',
# Comparison # # Comparison
'==', '!=', '<', '<=', '>', '>=', r'==', r'!=', r'<', r'<=', r'>', r'>=',
# Arithmetic # # Arithmetic
'\+', '-', '\*', '/', '//', '\%', '\*\*', r'\+', r"-", r'\*', r'/', r'//', r'%', r'\*\*',
# In-place # In-place
'\+=', '-=', '\*=', '/=', '\%=', r'\+=', r'-=', r'\*=', r'/=', r'\%=',
# Bitwise # Bitwise
'\^', '\|', '\&', '\~', '>>', '<<', r'\^', r'\|', r'&', r'~', r'>>', r'<<',
] ]
# Python braces # Python braces
braces = [ braces = [
'\{', '\}', '\(', '\)', '\[', '\]', r'\{', r'\}', r'\(', r'\)', r'\[', r'\]',
] ]
def __init__(self, document): def __init__(self, document):
@ -241,22 +236,21 @@ class PythonHighlighter(QSyntaxHighlighter):
# Multi-line strings (expression, flag, style) # Multi-line strings (expression, flag, style)
# FIXME: The triple-quotes in these two lines will mess up the # FIXME: The triple-quotes in these two lines will mess up the
# syntax highlighting from this point onward # syntax highlighting from this point onward
self.tri_single = (QRegExp("'''"), 1, 'string2') self.tri_single = (QRegularExpression("'''"), 1, 'string2')
self.tri_double = (QRegExp('"""'), 2, 'string2') self.tri_double = (QRegularExpression('"""'), 2, 'string2')
rules = [] rules = []
# Keyword, operator, and brace rules # Keyword, operator, and brace rules
rules += [(r'\b%s\b' % w, 0, 'keyword') rules += [(r'\b%s\b' % w, 0, 'keyword')
for w in PythonHighlighter.keywords] for w in PythonHighlighter.keywords]
rules += [(r'%s' % o, 0, 'operator') rules += [(o, 0, 'operator')
for o in PythonHighlighter.operators] for o in PythonHighlighter.operators]
rules += [(r'%s' % b, 0, 'brace') rules += [(b, 0, 'brace')
for b in PythonHighlighter.braces] for b in PythonHighlighter.braces]
# All other rules # All other rules
rules += [ rules += [
# 'self' # 'self'
(r'\bself\b', 0, 'self'), (r'\bself\b', 0, 'self'),
@ -277,12 +271,8 @@ class PythonHighlighter(QSyntaxHighlighter):
# From '#' until a newline # From '#' until a newline
(r'#[^\n]*', 0, 'comment'), (r'#[^\n]*', 0, 'comment'),
] ]
self.rules = rules
# Build a QRegExp for each pattern
self.rules = [(QRegExp(pat), index, fmt)
for (pat, index, fmt) in rules]
@property @property
def styles(self): def styles(self):
@ -294,16 +284,14 @@ class PythonHighlighter(QSyntaxHighlighter):
""" """
# Do other syntax formatting # Do other syntax formatting
for expression, nth, format in self.rules: for expression, nth, format in self.rules:
index = expression.indexIn(text, 0)
format = self.styles[format] format = self.styles[format]
while index >= 0: for n, match in enumerate(re.finditer(expression, text)):
# We actually want the index of the nth match if n < nth:
index = expression.pos(nth) continue
length = len(expression.cap(nth)) start = match.start()
self.setFormat(index, length, format) length = match.end() - start
index = expression.indexIn(text, index + length) self.setFormat(start, length, format)
self.setCurrentBlockState(0) self.setCurrentBlockState(0)
# Do multi-line strings # Do multi-line strings
@ -312,11 +300,16 @@ class PythonHighlighter(QSyntaxHighlighter):
in_multiline = self.match_multiline(text, *self.tri_double) in_multiline = self.match_multiline(text, *self.tri_double)
def match_multiline(self, text, delimiter, in_state, style): def match_multiline(self, text, delimiter, in_state, style):
"""Do highlighting of multi-line strings. ``delimiter`` should be a """Do highlighting of multi-line strings.
``QRegExp`` for triple-single-quotes or triple-double-quotes, and
``in_state`` should be a unique integer to represent the corresponding =========== ==========================================================
state changes when inside those strings. Returns True if we're still delimiter (QRegularExpression) for triple-single-quotes or
inside a multi-line string when this function is finished. triple-double-quotes
in_state (int) to represent the corresponding state changes when
inside those strings. Returns True if we're still inside a
multi-line string when this function is finished.
style (str) representation of the kind of style to use
=========== ==========================================================
""" """
# If inside triple-single quotes, start at 0 # If inside triple-single quotes, start at 0
if self.previousBlockState() == in_state: if self.previousBlockState() == in_state:
@ -324,17 +317,19 @@ class PythonHighlighter(QSyntaxHighlighter):
add = 0 add = 0
# Otherwise, look for the delimiter on this line # Otherwise, look for the delimiter on this line
else: else:
start = delimiter.indexIn(text) match = delimiter.match(text)
start = match.capturedStart()
# Move past this match # Move past this match
add = delimiter.matchedLength() add = match.capturedLength()
# As long as there's a delimiter match on this line... # As long as there's a delimiter match on this line...
while start >= 0: while start >= 0:
# Look for the ending delimiter # Look for the ending delimiter
end = delimiter.indexIn(text, start + add) match = delimiter.match(text, start + add)
end = match.capturedEnd()
# Ending delimiter on this line? # Ending delimiter on this line?
if end >= add: if end >= add:
length = end - start + add + delimiter.matchedLength() length = end - start + add + match.capturedLength()
self.setCurrentBlockState(0) self.setCurrentBlockState(0)
# No; multi-line string # No; multi-line string
else: else:
@ -343,7 +338,8 @@ class PythonHighlighter(QSyntaxHighlighter):
# Apply formatting # Apply formatting
self.setFormat(start, length, self.styles[style]) self.setFormat(start, length, self.styles[style])
# Look for the next match # Look for the next match
start = delimiter.indexIn(text, start + length) match = delimiter.match(text, start + length)
start = match.capturedStart()
# Return True if still inside a multi-line string, False otherwise # Return True if still inside a multi-line string, False otherwise
if self.currentBlockState() == in_state: if self.currentBlockState() == in_state:
@ -353,6 +349,7 @@ class PythonHighlighter(QSyntaxHighlighter):
class ExampleLoader(QtGui.QMainWindow): class ExampleLoader(QtGui.QMainWindow):
def __init__(self): def __init__(self):
QtGui.QMainWindow.__init__(self) QtGui.QMainWindow.__init__(self)