Skip to content

Commit

Permalink
fix dirwalk tests by explicitly setting mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuther committed May 7, 2024
1 parent 5953eb7 commit 7d96794
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/test_monster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# fun reading these tests as I had in writing them!

import datetime
import time
import os
import pathlib
import pytest
import time

from .common import TestCommon
from stempelwerk.DirWalk.DirWalk import dirwalk
Expand Down Expand Up @@ -53,6 +54,11 @@
TEST_FILES_AND_DIRS.append(entry)


def set_mtime_to_current_time(dir_path):
for path_in_directory in dirwalk(dir_path, include_directories=True):
os.utime(path_in_directory, times=None)


class TestMonster(TestCommon):

@pytest.mark.datafiles(FIXTURE_DIR)
Expand Down Expand Up @@ -419,8 +425,8 @@ def test_excluded_files_9(self, datafiles):

@pytest.mark.datafiles(FIXTURE_DIR)
def test_modified_1(self, datafiles):
# work around the peculiarities of "pytest-datafiles"
modified_since = datetime.datetime.now() - datetime.timedelta(days=2)
modified_since = datetime.datetime.now()
set_mtime_to_current_time(datafiles)

actual_paths = dirwalk(
datafiles,
Expand All @@ -433,8 +439,8 @@ def test_modified_1(self, datafiles):

@pytest.mark.datafiles(FIXTURE_DIR)
def test_modified_1_in_between(self, datafiles):
# work around the peculiarities of "pytest-datafiles"
modified_since = datetime.datetime.now() - datetime.timedelta(days=2)
modified_since = datetime.datetime.now()
set_mtime_to_current_time(datafiles)

actual_paths = dirwalk(
datafiles,
Expand Down

0 comments on commit 7d96794

Please sign in to comment.