Skip to content

Commit

Permalink
Merge pull request psychopy#6791 from TEParsons/dev-test-reduce-spam
Browse files Browse the repository at this point in the history
TEST: Reduce warnings spam from test suite
  • Loading branch information
TEParsons committed Aug 14, 2024
2 parents 725990a + c6a4dd6 commit 7f633fe
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion psychopy/app/_psychopyApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(self, parent=None, ID=-1, app=None, title="PsychoPy"):
class IDStore(dict):
"""A simpe class that works like a dict but you can access attributes
like standard python attrs. Useful to replace the previous pre-made
app.IDs (wx.NewID() is no longer recommended or safe)
app.IDs (wx.NewIdRef(count=1) is no longer recommended or safe)
"""
def __getattr__(self, attr):
return self[attr]
Expand Down
10 changes: 5 additions & 5 deletions psychopy/app/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ def makeMenus(self):
_translate("Save &as...\t%s") % keys['saveAs'],
_translate("Save current experiment file as..."))
# export html
self.menuIDs.ID_EXPORT_HTML = wx.NewId()
self.menuIDs.ID_EXPORT_HTML = wx.NewIdRef(count=1)
menu.Append(
self.menuIDs.ID_EXPORT_HTML,
_translate("Export HTML...\t%s") % keys['exportHTML'],
_translate("Export experiment to html/javascript file")
)
self.Bind(wx.EVT_MENU, self.fileExport, id=self.menuIDs.ID_EXPORT_HTML)
# reveal folder
self.menuIDs.ID_REVEAL = wx.NewId()
self.menuIDs.ID_REVEAL = wx.NewIdRef(count=1)
menu.Append(
self.menuIDs.ID_REVEAL,
_translate("Reveal in file explorer..."),
Expand All @@ -348,7 +348,7 @@ def makeMenus(self):
wx.ID_ANY, _translate("Reset preferences...")
)
self.Bind(wx.EVT_MENU, self.resetPrefs, item)
# item = menu.Append(wx.NewId(), "Plug&ins")
# item = menu.Append(wx.NewIdRef(count=1), "Plug&ins")
# self.Bind(wx.EVT_MENU, self.pluginManager, item)
self.fileMenu.AppendSeparator()
self.fileMenu.Append(wx.ID_EXIT,
Expand Down Expand Up @@ -4215,7 +4215,7 @@ def setDrawPoints(self, ptType, startPoint=None):

def drawLineStart(self, dc, pos):
# draw bar at start of timeline; circle looked bad, offset vertically
tmpId = wx.NewId()
tmpId = wx.NewIdRef(count=1)
dc.SetId(tmpId)
ptSize = (9, 9, 12)[self.appData['flowSize']]
thic = (1, 1, 2)[self.appData['flowSize']]
Expand All @@ -4229,7 +4229,7 @@ def drawLineStart(self, dc, pos):

def drawLineEnd(self, dc, pos):
# draws arrow at end of timeline
tmpId = wx.NewId()
tmpId = wx.NewIdRef(count=1)
dc.SetId(tmpId)
dc.SetBrush(wx.Brush(colors.app['fl_flowline_bg']))
dc.SetPen(wx.Pen(colors.app['fl_flowline_bg']))
Expand Down
14 changes: 7 additions & 7 deletions psychopy/app/coder/codeEditorBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def OnContextMenu(self, event):

if not hasattr(self, "UndoID"):
# Create a new ID for all items
self.UndoID = wx.NewId()
self.RedoID = wx.NewId()
self.CutID = wx.NewId()
self.CopyID = wx.NewId()
self.PasteID = wx.NewId()
self.DeleteID = wx.NewId()
self.SelectAllID = wx.NewId()
self.UndoID = wx.NewIdRef(count=1)
self.RedoID = wx.NewIdRef(count=1)
self.CutID = wx.NewIdRef(count=1)
self.CopyID = wx.NewIdRef(count=1)
self.PasteID = wx.NewIdRef(count=1)
self.DeleteID = wx.NewIdRef(count=1)
self.SelectAllID = wx.NewIdRef(count=1)

# Bind items to relevant method
self.Bind(wx.EVT_MENU, self.onUndo, id=self.UndoID)
Expand Down
8 changes: 4 additions & 4 deletions psychopy/app/coder/coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,9 @@ def outputContextMenu(self, event):
Provides menu items to clear all, select all and copy selected text."""
if not hasattr(self, "outputMenuID1"):
self.outputMenuID1 = wx.NewId()
self.outputMenuID2 = wx.NewId()
self.outputMenuID3 = wx.NewId()
self.outputMenuID1 = wx.NewIdRef(count=1)
self.outputMenuID2 = wx.NewIdRef(count=1)
self.outputMenuID3 = wx.NewIdRef(count=1)

self.Bind(wx.EVT_MENU, self.outputClear, id=self.outputMenuID1)
self.Bind(wx.EVT_MENU, self.outputSelectAll, id=self.outputMenuID2)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ def makeMenus(self):
wx.ID_ANY, _translate("Reset preferences...")
)
self.Bind(wx.EVT_MENU, self.resetPrefs, item)
# item = menu.Append(wx.NewId(), "Plug&ins")
# item = menu.Append(wx.NewIdRef(count=1), "Plug&ins")
# self.Bind(wx.EVT_MENU, self.pluginManager, id=item.GetId())
# -------------Close coder frame
menu.AppendSeparator()
Expand Down
6 changes: 3 additions & 3 deletions psychopy/app/coder/fileBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
FOLDER_TYPE_NO_ACCESS = 2

# IDs for menu events
ID_GOTO_BROWSE = wx.NewId()
ID_GOTO_CWD = wx.NewId()
ID_GOTO_FILE = wx.NewId()
ID_GOTO_BROWSE = wx.NewIdRef(count=1)
ID_GOTO_CWD = wx.NewIdRef(count=1)
ID_GOTO_FILE = wx.NewIdRef(count=1)


def convertBytes(nbytes):
Expand Down
2 changes: 1 addition & 1 deletion psychopy/app/themes/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def extractFaceNames(val):
# Make sure val is a list
if isinstance(val, str):
# Get rid of any perentheses
val = re.sub("[\(\)\[\]]", "", val)
val = re.sub(r"[\(\)\[\]]", "", val)
# Split by comma
val = val.split(",")
# Clear style markers
Expand Down
2 changes: 1 addition & 1 deletion psychopy/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ def sanitize(inStr):
"""
# Key-value pairs of patterns with what to replace them with
patterns = {
"https\:\/\/oauth2\:[\d\w]{64}@gitlab\.pavlovia\.org\/.*\.git": "[[OAUTH key hidden]]" # Remove any oauth keys
r"https:\/\/oauth2:[\d\w]{64}@gitlab\.pavlovia\.org\/.*\.git": "[[OAUTH key hidden]]" # Remove any oauth keys
}
# Replace each pattern
for pattern, repl in patterns.items():
Expand Down
4 changes: 2 additions & 2 deletions psychopy/monitors/MonitorCenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

# wx IDs for menu items
def newIds(n):
return [wx.NewId() for i in range(n)]
return [wx.NewIdRef(count=1) for i in range(n)]

[idMenuSave] = newIds(1)
# wx IDs for controllers (admin panel)
Expand Down Expand Up @@ -228,7 +228,7 @@ def makeMenuBar(self):

# Edit
editMenu = wx.Menu()
id = wx.NewId()
id = wx.NewIdRef(count=1)
_hint = _translate("Copy the current monitor's name to clipboard")
editMenu.Append(id, _translate('Copy\tCtrl+C'), _hint)
self.Bind(wx.EVT_MENU, self.onCopyMon, id=id)
Expand Down
6 changes: 3 additions & 3 deletions psychopy/projects/pavlovia.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,14 +1439,14 @@ def getNameWithNamespace(p):
universal_newlines=True) # newlines forces stdout to unicode
stdout, stderr = proc.communicate()
# Find a gitlab url in the response
url = re.match("https:\/\/gitlab\.pavlovia\.org\/\w*\/\w*\.git", stdout)
url = re.match(r"https:\/\/gitlab\.pavlovia\.org\/\w*\/\w*\.git", stdout)
if url:
# Get contents of url from response
url = url.string[url.pos:url.endpos]
# Get namespace/name string from url
path = url
path = re.sub("\.git[.\n]*", "", path)
path = re.sub("[.\n]*https:\/\/gitlab\.pavlovia\.org\/", "", path)
path = re.sub(r"\.git[.\n]*", "", path)
path = re.sub(r"[.\n]*https:\/\/gitlab\.pavlovia\.org\/", "", path)
return path
else:
return None
Expand Down
8 changes: 6 additions & 2 deletions psychopy/tests/test_experiment/test_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tempfile import mkdtemp

import numpy as np
import pandas as pd

from ..utils import TESTS_DATA_PATH
from psychopy import experiment, core, logging
Expand Down Expand Up @@ -63,8 +64,7 @@ def setup_class(cls):
if not datafile.is_file():
raise RuntimeError("Data file wasn't saved. PsychoPy StdErr below:\n" + stderr)
# Load data file
with open(datafile, "rb") as f:
data = np.recfromcsv(f, case_sensitive=True)
data = pd.read_csv(str(datafile)).values.tolist()

# Store
cls.cases[filename] = {
Expand All @@ -75,6 +75,10 @@ def setup_class(cls):
'stdout': stdout,
'stderr': stderr,
}

def teardown_class(cls):
# delete temp folder
shutil.rmtree(cls.tempDir)

def test_output_length(self):
"""
Expand Down
18 changes: 18 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ markers =
textbox
ratingscale
requires_wx
monitors
audioclip
imagetools
stringtools
viewtools
uax14
scalepos
stdroutines
emulator
keyboard
slow
staticperiod
quit
shellCall
event
info
localization
web
needs_sound: requires sound hw, thus should not be exercised e.g. on travis-ci
needs_pygame: requires pygame
needs_wx: can't be run where wxpython doesn't run (e.g. mac without pythonw)
Expand Down

0 comments on commit 7f633fe

Please sign in to comment.