Skip to content

R35-T010: Strengthen the tests of get_file_access_time (recently_acce… - #120

Open
nitteshx wants to merge 1 commit into
S-AI-Projects:mainfrom
nitteshx:student/e26b07f0629/R35-T010
Open

nitteshx wants to merge 1 commit into
S-AI-Projects:mainfrom
nitteshx:student/e26b07f0629/R35-T010

Conversation

@nitteshx

Copy link
Copy Markdown

This PR strengthens the tests of get_file_access_time in Recently Accessed Files/recently_accessed_files.py with mutation-resistant regression tests. The plausible one-line mutant (swapping os.path.getmtime for os.path.getatime) is detected by simultaneously mocking both functions with different values and asserting the return equals the access-time value.

Related Issue
Fixes: #10

Type of Change

  • Tests
  • Documentation
  • Refactoring / Maintenance

Changes Made

  • Added contract docstring to get_file_access_time naming the protected condition, plausible mutant, and distinguishing strategy.
  • Added 8 pytest tests in Recently Accessed Files/test_recently_accessed_files.py:
    • Smallest valid input (file_path="") → returns getatime 1000.0, is float, no mutation.
    • Ordinary input (file_path="/home/user/document.txt") → returns getatime 5000.0, path forwarded exactly.
    • Mutation-resistant: test_returns_atime_not_mtime — mocks getatime=1000.0 and getmtime=2000.0; original passes (1000.0), getmtime mutant fails (2000.0).
    • Mutation-resistant: test_returns_atime_not_ctime — same strategy for getctime mutant.
    • Mutation-resistant: ordinary input with distinct atime/mtime.
  • Implemented work/R35-T010/check.py, work/R35-T010/results.json, and work/R35-T010/evidence.md.

Screenshots / Recordings
There is no UI change.

Testing

  1. Ran python3 work/R35-T010/check.py: PASS (8/8 tests, 3 native checks).
  2. Ran FORCE_WRONG=1 python3 work/R35-T010/check.py: FAIL with non-zero exit code 1 (mutant detected).
  3. Ran python3 -m pytest "Recently Accessed Files/test_recently_accessed_files.py" -v: PASS (8 tests in 0.02s, 0 failures, 0 errors).

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes
All verification runner scripts, mutation analysis, and evidence are located under work/R35-T010/.

…ssed_files.py) [Recently Accessed Files]

- Add contract docstring naming plausible mutant: getmtime-for-getatime
- 8 pytest tests: smallest/ordinary fixture, path forwarding, 3 mutation-resistant tests
- Mutation-resistant: mock getatime=1000.0 and getmtime=2000.0 simultaneously; assert 1000.0
- Original passes, getmtime mutant returns 2000.0 and fails
- work/R35-T010/: check.py, evidence.md, results.json
- FORCE_WRONG=1 exits code 1 (verified)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant