Files
@ 0d155bc1eace
Branch filter:
Location: rattail-project/rattail/tests/test_files.py - annotation
0d155bc1eace
1.3 KiB
text/x-python
Tweak docs.
5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc 5aaf50e5b9bc | # -*- coding: utf-8 -*-
import os
from unittest import TestCase
import lockfile
from fixture import TempIO
from rattail import files
class TestLockingCopy(TestCase):
def setUp(self):
self.tmp = TempIO()
self.src = self.tmp.mkdir(u'src')
self.dst = self.tmp.mkdir(u'dst')
self.src_file = self.src.putfile(u'somefile', b'')
def test_normal_copy_succeeds(self):
files.locking_copy(self.src_file, self.dst)
dst_file = os.path.join(self.dst, u'somefile')
self.assertTrue(os.path.exists(dst_file))
self.assertTrue(os.path.isfile(dst_file))
self.assertFalse(os.path.exists(os.path.join(self.dst, u'somefile.lock')))
def test_copy_times_out_if_lock_already_exists(self):
dst_lock = self.dst.mkdir(u'somefile.lock')
self.assertRaises(lockfile.LockTimeout, files.locking_copy, self.src_file, self.dst, timeout=0.1)
def test_lock_timeout_may_be_specified_as_string(self):
dst_lock = self.dst.mkdir(u'somefile.lock')
# string "float"
self.assertRaises(lockfile.LockTimeout, files.locking_copy, self.src_file, self.dst, timeout=u'0.1')
# string "integer"
self.assertRaises(lockfile.LockTimeout, files.locking_copy, self.src_file, self.dst, timeout=u'1')
|