本文整理汇总了Python中tests.mkstemp函数的典型用法代码示例。如果您正苦于以下问题:Python mkstemp函数的具体用法?Python mkstemp怎么用?Python mkstemp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkstemp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
config.init()
self.main = mkdtemp()
self.dir1 = mkdtemp(dir=self.main)
self.dir2 = mkdtemp(dir=self.main)
h, self.cover1 = mkstemp(".png", dir=self.main)
os.close(h)
pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 10, 10)
pb.savev(self.cover1, "png", [], [])
h, self.cover2 = mkstemp(".png", dir=self.main)
os.close(h)
pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 20, 20)
pb.savev(self.cover2, "png", [], [])
fd, self.file1 = mkstemp(".mp3", dir=self.main)
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'silence-44-s.mp3'), self.file1)
fd, self.file2 = mkstemp(".mp3", dir=self.main)
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'silence-44-s.mp3'), self.file2)
self.manager = CoverManager()
开发者ID:bp0,项目名称:quodlibet,代码行数:27,代码来源:test_plugins_cover.py
示例2: setUp
def setUp(self):
config.init()
fd, self.filename = mkstemp(".mp3")
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'silence-44-s.mp3'), self.filename)
fd, self.filename2 = mkstemp(".mp3")
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'mutagen-bug.mp3'), self.filename2)
开发者ID:bp0,项目名称:quodlibet,代码行数:8,代码来源:test_formats__id3.py
示例3: setUp
def setUp(self):
fd, self.f = mkstemp(".wma")
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'test.wma'), self.f)
self.song = WMAFile(self.f)
fd, self.f2 = mkstemp(".wma")
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'test-2.wma'), self.f2)
self.song2 = WMAFile(self.f2)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:10,代码来源:test_formats_wma.py
示例4: setUp
def setUp(self):
config.init()
fd, self.f = mkstemp(".ogg")
os.close(fd)
fd, self.f2 = mkstemp(".mp3")
os.close(fd)
fd, self.f3 = mkstemp(".mp3")
os.write(fd, "garbage")
os.close(fd)
shutil.copy(os.path.join(DATA_DIR, 'silence-44-s.ogg'), self.f)
shutil.copy(os.path.join(DATA_DIR, 'silence-44-s.mp3'), self.f2)
self.s = MusicFile(self.f)
self.s2 = MusicFile(self.f2)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:13,代码来源:test_operon.py
示例5: test_validate
def test_validate(self):
with open(self.PATH, "rb") as template:
desktop_data = template.read()
# copy to a temp file and strip "_ from translatable entries
fd, name = mkstemp(suffix=".desktop")
os.close(fd)
with open(name, "wb") as temp:
new_lines = []
for l in desktop_data.splitlines():
if l.startswith("_"):
l = l[1:]
new_lines.append(l)
temp.write("\n".join(new_lines))
# pass to desktop-file-validate
try:
output = subprocess.check_output(
["desktop-file-validate", name], stderr=subprocess.STDOUT)
except OSError:
# desktop-file-validate not available
return
except subprocess.CalledProcessError as e:
output = e.output
finally:
os.remove(name)
if output:
raise Exception(output)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:29,代码来源:test_desktop_files.py
示例6: create_plugin
def create_plugin(self, id="", name="", desc="", icon="", funcs=None, mod=False):
fd, fn = mkstemp(suffix=".py", text=True, dir=self.tempdir)
file = os.fdopen(fd, "w")
if mod:
indent = ""
else:
file.write("from quodlibet.plugins.playlist import PlaylistPlugin\n")
file.write("class %s(PlaylistPlugin):\n" % name)
indent = " "
file.write("%spass\n" % indent)
if name:
file.write("%sPLUGIN_ID = %r\n" % (indent, name))
if name:
file.write("%sPLUGIN_NAME = %r\n" % (indent, name))
if desc:
file.write("%sPLUGIN_DESC = %r\n" % (indent, desc))
if icon:
file.write("%sPLUGIN_ICON = %r\n" % (indent, icon))
for f in funcs or []:
if f in ["__init__"]:
file.write(
"%sdef %s(self, *args): super(%s, self).__init__("
'*args); raise Exception("as expected.")\n' % (indent, f, name)
)
else:
file.write("%sdef %s(*args): return args\n" % (indent, f))
file.flush()
file.close()
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:30,代码来源:test_plugins_playlist.py
示例7: test_savedsearch
def test_savedsearch(self):
if 'include_saved' not in self.plugins:
return
plugin = self.plugins['include_saved'].cls()
self.failUnlessRaises(QueryPluginError, plugin.parse_body, None)
try:
fd, filename = mkstemp(text=True)
file = os.fdopen(fd, 'w')
file.write("artist=a\nQuery 1\ngenre=classical\nAnother query")
file.close()
self.failUnlessRaises(QueryPluginError, plugin.parse_body,
'missing query')
self.failUnlessRaises(QueryPluginError, plugin.parse_body,
'artist=a')
self.failUnless(plugin.parse_body(' quEry 1',
query_path_=filename))
query1 = plugin.parse_body('Query 1', query_path_=filename)
query2 = plugin.parse_body('another query', query_path_=filename)
song = AudioFile({'artist': u'a', 'genre': u'dance'})
self.failUnless(plugin.search(song, query1))
self.failIf(plugin.search(song, query2))
finally:
os.remove(filename)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:29,代码来源:test_query.py
示例8: test_trash_removes_file
def test_trash_removes_file(self):
filename = mkstemp()[1]
with open(filename, "w") as f:
f.write("\n")
self.failUnless(os.path.exists(filename))
trash(filename)
self.failIf(os.path.exists(filename))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_util_trash.py
示例9: setUp
def setUp(self):
quodlibet.config.init()
h, self.fname = mkstemp()
os.close(h)
with open(self.fname + ".saved", "w") as f:
f.write("%s\n%s\n" % (self.TEST_KV_DATA[0][1], self.TEST_KV_DATA[0][0]))
self.sae = StandaloneEditor(self.fname, "test", None, None)
开发者ID:mistotebe,项目名称:quodlibet,代码行数:7,代码来源:test_qltk_cbes.py
示例10: setUp
def setUp(self):
config.init()
init_fake_app()
fd, self.fn = mkstemp()
os.close(fd)
pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 150, 10)
pb.savev(self.fn, "png", [], [])
开发者ID:LudoBike,项目名称:quodlibet,代码行数:7,代码来源:test_qltk_cover.py
示例11: setUp
def setUp(self):
TVCCover.setUp(self)
h, self.filename = mkstemp(".flac")
os.close(h)
shutil.copy(os.path.join(DATA_DIR, 'empty.flac'), self.filename)
self.MutagenType = FLAC
self.QLType = FLACFile
开发者ID:mistotebe,项目名称:quodlibet,代码行数:7,代码来源:test_formats_xiph.py
示例12: create_plugin
def create_plugin(self, id='', name='', desc='', icon='',
funcs=None, mod=False):
fd, fn = mkstemp(suffix='.py', text=True, dir=self.tempdir)
file = os.fdopen(fd, 'w')
if mod:
indent = ''
else:
file.write(
"from quodlibet.plugins.songsmenu import SongsMenuPlugin\n")
file.write("class %s(SongsMenuPlugin):\n" % name)
indent = ' '
file.write("%spass\n" % indent)
if name:
file.write("%sPLUGIN_ID = %r\n" % (indent, name))
if name:
file.write("%sPLUGIN_NAME = %r\n" % (indent, name))
if desc:
file.write("%sPLUGIN_DESC = %r\n" % (indent, desc))
if icon:
file.write("%sPLUGIN_ICON = %r\n" % (indent, icon))
for f in (funcs or []):
if f in ["__init__"]:
file.write("%sdef %s(self, *args): super(%s, self).__init__("
"*args); raise Exception(\"as expected\")\n"
% (indent, f, name))
else:
file.write("%sdef %s(*args): return args\n" % (indent, f))
file.flush()
file.close()
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:31,代码来源:test_plugins_songsmenu.py
示例13: setUp
def setUp(self):
from gi.repository import GdkPixbuf
h, self.filename = mkstemp()
os.close(h)
pb = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 150, 10)
pb.savev(self.filename, "png", [], [])
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:7,代码来源:test_formats__image.py
示例14: test_validate
def test_validate(self):
# strip translatable prefix from tags
from xml.etree import ElementTree
tree = ElementTree.parse(self.PATH)
for x in tree.iter():
if x.tag.startswith("_"):
x.tag = x.tag[1:]
fd, name = mkstemp(suffix=".appdata.xml")
os.close(fd)
with open(name, "wb") as temp:
header = open(self.PATH, "rb").read().splitlines()[0]
temp.write(header + "\n")
temp.write(ElementTree.tostring(tree.getroot(), encoding="utf-8"))
# pass to desktop-file-validate
try:
subprocess.check_output(
["appdata-validate", "--nonet", name],
stderr=subprocess.STDOUT)
except OSError:
# appdata-validate not available
return
except subprocess.CalledProcessError as e:
raise Exception(e.output)
finally:
os.remove(name)
开发者ID:brunob,项目名称:quodlibet,代码行数:27,代码来源:test_appdata_files.py
示例15: test_load_noexist
def test_load_noexist(self):
fd, filename = mkstemp()
os.close(fd)
os.unlink(filename)
library = self.Library()
library.load(filename)
assert len(library) == 0
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:test_library_libraries.py
示例16: test_parse_empty
def test_parse_empty(self):
h, name = mkstemp()
os.close(h)
open(name, "w").close()
pl = self.Parse(name)
os.unlink(name)
self.failUnlessEqual(0, len(pl))
pl.delete()
开发者ID:bossjones,项目名称:quodlibet,代码行数:8,代码来源:test_browsers_playlists.py
示例17: test_from_path_empty
def test_from_path_empty(self):
h, empty = mkstemp()
os.close(h)
try:
image = EmbeddedImage.from_path(empty)
self.assertFalse(image)
finally:
os.remove(empty)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:8,代码来源:test_formats__image.py
示例18: test_hidden_dir
def test_hidden_dir(self):
child = mkdtemp(dir=self.root, prefix=".")
fd, name = mkstemp(dir=child)
os.close(fd)
assert list(iter_paths(child)) == []
assert list(iter_paths(child, skip_hidden=False)) == [name]
assert list(iter_paths(self.root)) == []
assert list(iter_paths(self.root, skip_hidden=False)) == [name]
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:8,代码来源:test_library_libraries.py
示例19: test_one_file_exclude
def test_one_file_exclude(self):
fd, name = mkstemp(dir=self.root)
os.close(fd)
assert list(iter_paths(self.root, exclude=[self.root])) == []
assert list(iter_paths(self.root,
exclude=[os.path.dirname(self.root)])) == []
assert list(iter_paths(self.root, exclude=[name])) == []
assert list(iter_paths(self.root, exclude=[name + "a"])) == [name]
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:8,代码来源:test_library_libraries.py
示例20: enabled
def enabled(self):
# https://github.com/quodlibet/quodlibet/issues/1093
fd, filename = mkstemp('.shelve')
os.close(fd)
os.unlink(filename)
s = shelve.open(filename)
s["foobar"] = PickleMe()
s.close()
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:8,代码来源:pickle_test.py
注:本文中的tests.mkstemp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论