Skip to content

Commit

Permalink
Added tests for newer_pairwise_group().
Browse files Browse the repository at this point in the history
Cherry-picked from pypa/setuptools@a40114a.
  • Loading branch information
Daniel Nunes authored and jaraco committed Nov 5, 2023
1 parent 2972e29 commit 378d0d5
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion distutils/tests/test_modified.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for distutils._modified."""
import os

from distutils._modified import newer, newer_pairwise, newer_group
from distutils._modified import newer, newer_pairwise, newer_group, newer_pairwise_group
from distutils.errors import DistutilsFileError
from distutils.tests import support
import pytest
Expand Down Expand Up @@ -89,3 +89,30 @@ def test_newer_group(self):
assert not newer_group([one, two, old_file], three, missing='ignore')

assert newer_group([one, two, old_file], three, missing='newer')


@pytest.fixture
def groups_target(tmpdir):
"""Sets up some older sources, a target and newer sources.
Returns a 3-tuple in this order.
"""
creation_order = ['older.c', 'older.h', 'target.o', 'newer.c', 'newer.h']
mtime = 0

for i in range(len(creation_order)):
creation_order[i] = os.path.join(str(tmpdir), creation_order[i])
with open(creation_order[i], 'w'):
pass

# make sure modification times are sequential
os.utime(creation_order[i], (mtime, mtime))
mtime += 1

return creation_order[:2], creation_order[2], creation_order[3:]


def test_newer_pairwise_group(groups_target):
older = newer_pairwise_group([groups_target[0]], [groups_target[1]])
newer = newer_pairwise_group([groups_target[2]], [groups_target[1]])
assert older == ([], [])
assert newer == ([groups_target[2]], [groups_target[1]])

0 comments on commit 378d0d5

Please sign in to comment.