Esempio n. 1
0
def test_atime_not_modified(tmp_path):
    filepath = tmp_path / "test_atime_not_modified.txt"
    filepath.touch()
    before = os.path.getatime(str(filepath))
    time.sleep(0.1)
    setctime(filepath, 123456789)
    assert os.path.getatime(str(filepath)) == before
Esempio n. 2
0
def test_file_already_opened_read(tmp_path):
    filepath = tmp_path / "test_file_already_opened_read.txt"
    timestamp = 123456789
    filepath.touch()
    with open(str(filepath), "r"):
        setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 3
0
def test_forward_slash(tmp_path):
    folder = tmp_path / "foo" / "bar" / "baz"
    filepath = folder / "test_forward_slash.txt"
    timestamp = 123456789
    folder.mkdir(exist_ok=True, parents=True)
    filepath.touch()
    setctime(str(filepath).replace(r"\\", "/"), timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 4
0
def test_fix_file_tunneling(tmp_path):
    filepath = tmp_path / "test_fix_file_tunneling.txt"
    timestamp = 123456789
    filepath.touch()
    before = getctime(filepath)
    time.sleep(0.1)
    os.remove(str(filepath))
    filepath.touch()
    assert getctime(filepath) == before
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 5
0
def test_file_already_opened_exclusive(tmp_path):
    filepath = tmp_path / "test_file_already_opened_write.txt"
    timestamp = 123456789
    with open(str(filepath), "x"):
        setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 6
0
def test_file_does_not_exist(tmp_path):
    filepath = tmp_path / "test_file_does_not_exist.txt"
    timestamp = 123456789
    with pytest.raises(FileNotFoundError):
        setctime(filepath, timestamp)
Esempio n. 7
0
def test_timestamp_exceeds_upper_bound(tmp_path):
    filepath = tmp_path / "test_timestamp_exceeds_upper_bound.txt"
    timestamp = 1833029933770.9551616
    filepath.touch()
    with pytest.raises(ValueError):
        setctime(filepath, timestamp)
Esempio n. 8
0
def test_timestamp_far_in_the_future(tmp_path):
    filepath = tmp_path / "test_timestamp_far_in_the_future.txt"
    timestamp = 64675581821
    filepath.touch()
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 9
0
def test_timestamp_exceeds_lower_bound(tmp_path):
    filepath = tmp_path / "test_timestamp_exceeds_lower_bound.txt"
    timestamp = -11644473600
    filepath.touch()
    with pytest.raises(ValueError):
        setctime(filepath, timestamp)
Esempio n. 10
0
def test_timestamp_lower_bound(tmp_path):
    filepath = tmp_path / "test_timestamp_lower_sdfds.dds"
    timestamp = -11644473599
    filepath.touch()
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 11
0
def test_timestamp_with_nanoseconds(tmp_path):
    filepath = tmp_path / "test_timestamp_with_nanoseconds.txt"
    timestamp = 737206464.123456789
    filepath.touch()
    setctime(filepath, timestamp)
    assert pytest.approx(getctime(filepath), timestamp)
Esempio n. 12
0
def test_timestamp_negative(tmp_path):
    filepath = tmp_path / "test_timestamp_negative.txt"
    timestamp = -5694948000
    filepath.touch()
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 13
0
def test_setctime(tmp_path):
    filepath = tmp_path / "test_setctime.txt"
    timestamp = 946681200
    filepath.touch()
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp
Esempio n. 14
0
def test_file_unicode(tmp_path):
    filepath = tmp_path / "𤭢.txt"
    timestamp = 123456789
    filepath.touch()
    setctime(filepath, timestamp)
    assert getctime(filepath) == timestamp