Skip to content

Commit

Permalink
tests: avoid false error when checking if the parser is up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuDartiailh committed Feb 21, 2023
1 parent 1abd838 commit 511f01e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""Pytest fixtures.
"""
import math
import os
import pathlib
from traceback import format_exc
Expand Down Expand Up @@ -73,10 +74,16 @@ def validate_parser_is_up_to_date():
last_source_modif = max(
os.path.getmtime(base_enaml_parser.__file__),
os.path.getmtime(base_python_parser.__file__),
os.path.getmtime(pathlib.Path(base_enaml_parser.__file__).parent / "enaml.gram"),
os.path.getmtime(
pathlib.Path(base_enaml_parser.__file__).parent / "enaml.gram"
),
)

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

@pytest.fixture
def enaml_qtbot(qt_app, qtbot):

qtbot.enaml_app = qt_app
pixel_ratio = QtGui.QGuiApplication.primaryScreen().devicePixelRatio()

Expand Down

0 comments on commit 511f01e

Please sign in to comment.