mirror of
https://github.com/arsenetar/send2trash.git
synced 2025-05-08 09:49:52 +00:00
Update Windows test
This commit is contained in:
parent
d1f8b4a2db
commit
959f9044ae
@ -8,12 +8,40 @@ from tempfile import gettempdir
|
|||||||
from send2trash import send2trash as s2t
|
from send2trash import send2trash as s2t
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform != 'win32', 'Windows only')
|
||||||
|
class TestNormal(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.dirname = '\\\\?\\' + op.join(gettempdir(), 'python.send2trash')
|
||||||
|
self.file = op.join(self.dirname, 'testfile.txt')
|
||||||
|
self._create_tree(self.file)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
os.remove(self.dirname)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _create_tree(self, path):
|
||||||
|
dirname = op.dirname(path)
|
||||||
|
if not op.isdir(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
|
with open(path, 'w') as writer:
|
||||||
|
writer.write('send2trash test')
|
||||||
|
|
||||||
|
def test_trash_file(self):
|
||||||
|
s2t(self.file)
|
||||||
|
self.assertFalse(op.exists(self.file))
|
||||||
|
|
||||||
|
def test_file_not_found(self):
|
||||||
|
file = op.join(self.dirname, 'otherfile.txt')
|
||||||
|
self.assertRaises(WindowsError, s2t, file)
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform != 'win32', 'Windows only')
|
@unittest.skipIf(sys.platform != 'win32', 'Windows only')
|
||||||
class TestLongPath(unittest.TestCase):
|
class TestLongPath(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
filename = 'A' * 100
|
filename = 'A' * 100
|
||||||
self.dirname = '\\\\?\\' + os.path.join(gettempdir(), filename)
|
self.dirname = '\\\\?\\' + op.join(gettempdir(), filename)
|
||||||
self.file = os.path.join(
|
self.file = op.join(
|
||||||
self.dirname,
|
self.dirname,
|
||||||
filename,
|
filename,
|
||||||
filename, # From there, the path is not trashable from Explorer
|
filename, # From there, the path is not trashable from Explorer
|
||||||
@ -28,8 +56,8 @@ class TestLongPath(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _create_tree(self, path):
|
def _create_tree(self, path):
|
||||||
dirname = os.path.dirname(path)
|
dirname = op.dirname(path)
|
||||||
if not os.path.isdir(dirname):
|
if not op.isdir(dirname):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
with open(path, 'w') as writer:
|
with open(path, 'w') as writer:
|
||||||
writer.write('Looong filename!')
|
writer.write('Looong filename!')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user