本文整理汇总了Python中test._common.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了touch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_main_interface_gives_precedence_to_fs_art
def test_main_interface_gives_precedence_to_fs_art(self):
_common.touch(os.path.join(self.dpath, b'art.jpg'))
self.mock_response(self.AMAZON_URL)
album = _common.Bag(asin=self.ASIN)
candidate = self.plugin.art_for_album(album, [self.dpath])
self.assertIsNotNone(candidate)
self.assertEqual(candidate.path, os.path.join(self.dpath, b'art.jpg'))
示例2: test_local_only_gets_fs_image
def test_local_only_gets_fs_image(self):
_common.touch(os.path.join(self.dpath, 'art.jpg'))
album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
artpath = self.plugin.art_for_album(album, [self.dpath],
local_only=True)
self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg'))
self.assertEqual(len(responses.calls), 0)
示例3: test_local_only_gets_fs_image
def test_local_only_gets_fs_image(self):
_common.touch(os.path.join(self.dpath, b"art.jpg"))
album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
candidate = self.plugin.art_for_album(album, [self.dpath], local_only=True)
self.assertIsNotNone(candidate)
self.assertEqual(candidate.path, os.path.join(self.dpath, b"art.jpg"))
self.assertEqual(len(responses.calls), 0)
示例4: setUp
def setUp(self):
super(UpdateTest, self).setUp()
self.io.install()
self.libdir = os.path.join(self.temp_dir, b'testlibdir')
# Copy a file into the library.
self.lib = library.Library(':memory:', self.libdir)
item_path = os.path.join(_common.RSRC, b'full.mp3')
item_path_two = os.path.join(_common.RSRC, b'full.flac')
self.i = library.Item.from_path(item_path)
self.i2 = library.Item.from_path(item_path_two)
self.lib.add(self.i)
self.lib.add(self.i2)
self.i.move(operation=MoveOperation.COPY)
self.i2.move(operation=MoveOperation.COPY)
self.album = self.lib.add_album([self.i, self.i2])
# Album art.
artfile = os.path.join(self.temp_dir, b'testart.jpg')
_common.touch(artfile)
self.album.set_art(artfile)
self.album.store()
os.remove(artfile)
示例5: test_precedence_amongst_correct_files
def test_precedence_amongst_correct_files(self):
images = [b"front-cover.jpg", b"front.jpg", b"back.jpg"]
paths = [os.path.join(self.dpath, i) for i in images]
for p in paths:
_common.touch(p)
self.extra["cover_names"] = ["cover", "front", "back"]
candidates = [candidate.path for candidate in self.source.get(None, self.extra)]
self.assertEqual(candidates, paths)
示例6: setUp
def setUp(self):
super(SafeMoveCopyTest, self).setUp()
self.path = os.path.join(self.temp_dir, 'testfile')
touch(self.path)
self.otherpath = os.path.join(self.temp_dir, 'testfile2')
touch(self.otherpath)
self.dest = self.path + '.dest'
示例7: test_removing_last_item_in_album_with_albumart_prunes_dir
def test_removing_last_item_in_album_with_albumart_prunes_dir(self):
artfile = os.path.join(self.temp_dir, 'testart.jpg')
touch(artfile)
self.ai.set_art(artfile)
self.ai.store()
parent = os.path.dirname(self.i.path)
self.i.remove(True)
self.assertNotExists(parent)
示例8: test_precedence_amongst_correct_files
def test_precedence_amongst_correct_files(self):
images = [b'front-cover.jpg', b'front.jpg', b'back.jpg']
paths = [os.path.join(self.dpath, i) for i in images]
for p in paths:
_common.touch(p)
self.settings.cover_names = ['cover', 'front', 'back']
candidates = [candidate.path for candidate in
self.source.get(None, self.settings, [self.dpath])]
self.assertEqual(candidates, paths)
示例9: test_move_avoids_collision_with_existing_file
def test_move_avoids_collision_with_existing_file(self):
# Make a conflicting file at the destination.
dest = self.i.destination()
os.makedirs(os.path.dirname(dest))
touch(dest)
self.i.move()
self.assertNotEqual(self.i.path, dest)
self.assertEqual(os.path.dirname(self.i.path),
os.path.dirname(dest))
示例10: test_setart_copies_image
def test_setart_copies_image(self):
os.remove(self.art)
newart = os.path.join(self.libdir, 'newart.jpg')
touch(newart)
i2 = item()
i2.path = self.i.path
i2.artist = u'someArtist'
ai = self.lib.add_album((i2,))
i2.move(True)
self.assertEqual(ai.artpath, None)
ai.set_art(newart)
self.assertTrue(os.path.exists(ai.artpath))
示例11: test_setart_to_existing_but_unset_art_works
def test_setart_to_existing_but_unset_art_works(self):
newart = os.path.join(self.libdir, 'newart.jpg')
touch(newart)
i2 = item()
i2.path = self.i.path
i2.artist = u'someArtist'
ai = self.lib.add_album((i2,))
i2.move(True)
# Copy the art to the destination.
artdest = ai.art_destination(newart)
shutil.copy(newart, artdest)
# Set the art again.
ai.set_art(artdest)
self.assertTrue(os.path.exists(ai.artpath))
示例12: test_setart_to_existing_art_works
def test_setart_to_existing_art_works(self):
os.remove(self.art)
# Original art.
newart = os.path.join(self.libdir, 'newart.jpg')
touch(newart)
i2 = item()
i2.path = self.i.path
i2.artist = u'someArtist'
ai = self.lib.add_album((i2,))
i2.move(True)
ai.set_art(newart)
# Set the art again.
ai.set_art(ai.artpath)
self.assertTrue(os.path.exists(ai.artpath))
示例13: test_setart_to_conflicting_file_gets_new_path
def test_setart_to_conflicting_file_gets_new_path(self):
newart = os.path.join(self.libdir, 'newart.jpg')
touch(newart)
i2 = item()
i2.path = self.i.path
i2.artist = u'someArtist'
ai = self.lib.add_album((i2,))
i2.move(True)
# Make a file at the destination.
artdest = ai.art_destination(newart)
touch(artdest)
# Set the art.
ai.set_art(newart)
self.assertNotEqual(artdest, ai.artpath)
self.assertEqual(os.path.dirname(artdest),
os.path.dirname(ai.artpath))
示例14: setUp
def setUp(self):
super(ArtImporterTest, self).setUp()
# Mock the album art fetcher to always return our test file.
self.art_file = os.path.join(self.temp_dir, 'tmpcover.jpg')
_common.touch(self.art_file)
self.old_afa = self.plugin.art_for_album
self.afa_response = self.art_file
def art_for_album(i, p, local_only=False):
return self.afa_response
self.plugin.art_for_album = art_for_album
# Test library.
self.libpath = os.path.join(self.temp_dir, 'tmplib.blb')
self.libdir = os.path.join(self.temp_dir, 'tmplib')
os.mkdir(self.libdir)
os.mkdir(os.path.join(self.libdir, 'album'))
itempath = os.path.join(self.libdir, 'album', 'test.mp3')
shutil.copyfile(os.path.join(_common.RSRC, 'full.mp3'), itempath)
self.lib = library.Library(self.libpath)
self.i = _common.item()
self.i.path = itempath
self.album = self.lib.add_album([self.i])
self.lib._connection().commit()
# The import configuration.
self.session = _common.import_session(self.lib)
# Import task for the coroutine.
self.task = importer.ImportTask(None, None, [self.i])
self.task.is_album = True
self.task.album = self.album
info = AlbumInfo(
album='some album',
album_id='albumid',
artist='some artist',
artist_id='artistid',
tracks=[],
)
self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
示例15: setUp
def setUp(self):
super(UpdateTest, self).setUp()
self.io.install()
self.libdir = os.path.join(self.temp_dir, 'testlibdir')
# Copy a file into the library.
self.lib = library.Library(':memory:', self.libdir)
self.i = library.Item.from_path(os.path.join(_common.RSRC, 'full.mp3'))
self.lib.add(self.i)
self.i.move(True)
self.album = self.lib.add_album([self.i])
# Album art.
artfile = os.path.join(self.temp_dir, 'testart.jpg')
_common.touch(artfile)
self.album.set_art(artfile)
self.album.store()
os.remove(artfile)