Skip to content

Commit 511f01e

Browse files
tests: avoid false error when checking if the parser is up to date
1 parent 1abd838 commit 511f01e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/conftest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""Pytest fixtures.
99
1010
"""
11+
import math
1112
import os
1213
import pathlib
1314
from traceback import format_exc
@@ -73,10 +74,16 @@ def validate_parser_is_up_to_date():
7374
last_source_modif = max(
7475
os.path.getmtime(base_enaml_parser.__file__),
7576
os.path.getmtime(base_python_parser.__file__),
76-
os.path.getmtime(pathlib.Path(base_enaml_parser.__file__).parent / "enaml.gram"),
77+
os.path.getmtime(
78+
pathlib.Path(base_enaml_parser.__file__).parent / "enaml.gram"
79+
),
7780
)
7881

79-
assert os.path.getmtime(enaml_parser.__file__) >= last_source_modif, (
82+
# We round the times to avoid spurious failure because both files were
83+
# written at slightly different times.
84+
assert math.ceil(os.path.getmtime(enaml_parser.__file__)) >= math.floor(
85+
last_source_modif
86+
), (
8087
"Generated parser appears outdated compared to its sources, "
8188
"re-generate it using enaml/core/parser/generate_enaml_parser.enaml"
8289
)
@@ -109,7 +116,6 @@ def qt_app():
109116

110117
@pytest.fixture
111118
def enaml_qtbot(qt_app, qtbot):
112-
113119
qtbot.enaml_app = qt_app
114120
pixel_ratio = QtGui.QGuiApplication.primaryScreen().devicePixelRatio()
115121

0 commit comments

Comments
 (0)