本文整理汇总了Python中test._common.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了touch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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'))
开发者ID:beetbox,项目名称:beets,代码行数:7,代码来源:test_art.py
示例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)
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:7,代码来源:test_art.py
示例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)
开发者ID:jcoady9,项目名称:beets,代码行数:7,代码来源:test_art.py
示例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)
开发者ID:beetbox,项目名称:beets,代码行数:25,代码来源:test_ui.py
示例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)
开发者ID:jcoady9,项目名称:beets,代码行数:8,代码来源:test_art.py
示例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'
开发者ID:RyanScottLewis,项目名称:beets,代码行数:8,代码来源:test_files.py
示例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)
开发者ID:RyanScottLewis,项目名称:beets,代码行数:9,代码来源:test_files.py
示例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)
开发者ID:beetbox,项目名称:beets,代码行数:9,代码来源:test_art.py
示例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))
开发者ID:RyanScottLewis,项目名称:beets,代码行数:10,代码来源:test_files.py
示例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))
开发者ID:RyanScottLewis,项目名称:beets,代码行数:14,代码来源:test_files.py
示例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))
开发者ID:RyanScottLewis,项目名称:beets,代码行数:16,代码来源:test_files.py
示例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))
开发者ID:RyanScottLewis,项目名称:beets,代码行数:16,代码来源:test_files.py
示例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))
开发者ID:RyanScottLewis,项目名称:beets,代码行数:18,代码来源:test_files.py
示例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()))
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:42,代码来源:test_art.py
示例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)
开发者ID:reficull,项目名称:beets,代码行数:20,代码来源:test_ui.py
示例16: test_setart_sets_permissions
def test_setart_sets_permissions(self):
os.remove(self.art)
newart = os.path.join(self.libdir, 'newart.jpg')
touch(newart)
os.chmod(newart, 0o400) # read-only
try:
i2 = item()
i2.path = self.i.path
i2.artist = u'someArtist'
ai = self.lib.add_album((i2,))
i2.move(True)
ai.set_art(newart)
mode = stat.S_IMODE(os.stat(ai.artpath).st_mode)
self.assertTrue(mode & stat.S_IRGRP)
self.assertTrue(os.access(ai.artpath, os.W_OK))
finally:
# Make everything writable so it can be cleaned up.
os.chmod(newart, 0o777)
os.chmod(ai.artpath, 0o777)
开发者ID:RyanScottLewis,项目名称:beets,代码行数:23,代码来源:test_files.py
示例17: test_precedence_amongst_correct_files
def test_precedence_amongst_correct_files(self):
_common.touch(os.path.join(self.dpath, 'back.jpg'))
_common.touch(os.path.join(self.dpath, 'front.jpg'))
_common.touch(os.path.join(self.dpath, 'front-cover.jpg'))
fn = self.source.get(self.dpath, ('cover', 'front', 'back'), False)
self.assertEqual(fn, os.path.join(self.dpath, 'front-cover.jpg'))
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:6,代码来源:test_art.py
示例18: test_cautious_skips_fallback
def test_cautious_skips_fallback(self):
_common.touch(os.path.join(self.dpath, 'a.jpg'))
fn = self.source.get(self.dpath, ('art',), True)
self.assertEqual(fn, None)
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:4,代码来源:test_art.py
示例19: test_non_image_file_not_identified
def test_non_image_file_not_identified(self):
_common.touch(os.path.join(self.dpath, 'a.txt'))
fn = self.source.get(self.dpath, ('art',), False)
self.assertEqual(fn, None)
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:4,代码来源:test_art.py
示例20: test_appropriately_named_file_takes_precedence
def test_appropriately_named_file_takes_precedence(self):
_common.touch(os.path.join(self.dpath, 'a.jpg'))
_common.touch(os.path.join(self.dpath, 'art.jpg'))
fn = self.source.get(self.dpath, ('art',), False)
self.assertEqual(fn, os.path.join(self.dpath, 'art.jpg'))
开发者ID:hiro-sumi1888,项目名称:beets,代码行数:5,代码来源:test_art.py
注:本文中的test._common.touch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论