Skip to content

Commit

Permalink
TEST: Remove timestamps from compiled scripts when comparing, otherwi…
Browse files Browse the repository at this point in the history
…se the line with the time on will be different if compile took >1s
  • Loading branch information
Todd authored and Todd committed Mar 31, 2021
1 parent 69798cd commit cf05a1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions psychopy/tests/test_app/test_builder/test_Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from lxml import etree
import numpy
import sys
import re

# Jeremy Gray March 2011

Expand All @@ -32,6 +33,7 @@
# load should change things

allComponents = psychopy.experiment.getComponents(fetchIcons=False)
isTime = re.compile(r"\d+:\d+(:\d+)?( [AP]M)?")


def _filterout_legal(lines):
Expand Down Expand Up @@ -91,6 +93,9 @@ def test_xml(self):
exp.loadFromXML(temp)
# Compile again
test = exp.writeScript()
# Remove any timestamps from script (these can cause false errors if compile takes longer than a second)
test = re.sub(isTime, "", test)
target = re.sub(isTime, "", target)
# Compare two scripts to make sure saving and loading hasn't changed anything
diff = difflib.unified_diff(target.splitlines(), test.splitlines())
assert list(diff) == []
Expand Down

0 comments on commit cf05a1c

Please sign in to comment.