• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.new_notebook函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.new_notebook函数的典型用法代码示例。如果您正苦于以下问题:Python new_notebook函数的具体用法?Python new_notebook怎么用?Python new_notebook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了new_notebook函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setupGtkInterface

def setupGtkInterface(test, klass=None, notebook=None):
	'''Setup a new GtkInterface object for testing.
	Will have test notebook, and default preferences.
	@param test: the test that wants to use this ui object
	@param klass: the klass to use, defaults to L{GtkInterface}, but
	could be partially mocked subclass
	'''
	if klass is None:
		klass = zim.gui.GtkInterface

	# start filtering
	filter = FilterNoSuchImageWarning()
	filter.wrap_test(test)


	# create interface object with new notebook
	if notebook is None:
		dirpath = test.get_tmp_name()
		notebook = tests.new_notebook(fakedir=dirpath)

	config = VirtualConfigManager()
	ui = klass(config=config, notebook=notebook)

	ui.mainwindow.init_uistate()
	ui.open_page(Path('Test:foo:bar'))

	return ui
开发者ID:fabricehong,项目名称:zim-desktop,代码行数:27,代码来源:gui.py


示例2: runTest

	def runTest(self):
		'''Test proper linking of files in export'''
		notebook = tests.new_notebook(fakedir='/source/dir/')

		linker = StaticLinker('html', notebook)
		linker.set_usebase(True) # normally set by html format module
		linker.set_path(Path('foo:bar')) # normally set by exporter
		linker.set_base(Dir('/source/dir/foo')) # normally set by exporter

		self.assertEqual(linker.link_page('+dus'), './bar/dus.html')
		self.assertEqual(linker.link_page('dus'), './dus.html')
		self.assertEqual(linker.link_file('./dus.pdf'), './bar/dus.pdf')
		self.assertEqual(linker.link_file('../dus.pdf'), './dus.pdf')
		self.assertEqual(linker.link_file('../../dus.pdf'), '../dus.pdf')

		## setup environment for interwiki link
		if os.name == 'nt':
			uri = 'file:///C:/foo'
		else:
			uri = 'file:///foo'

		list = get_notebook_list()
		list.append(NotebookInfo(uri, interwiki='foo'))
		list.write()
		##

		href = interwiki_link('foo?Ideas:Task List')
		self.assertIsNotNone(href)
		self.assertEqual(linker.link('foo?Ideas:Task List'), uri + '/Ideas/Task_List.txt')
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:29,代码来源:export.py


示例3: testTemplate

	def testTemplate(self):
		pluginklass = zim.plugins.get_plugin_class('calendar')
		plugin = pluginklass()

		notebook = tests.new_notebook()

		template = get_template('wiki', 'Journal')
		zim.datetimetz.FIRST_DAY_OF_WEEK = \
			zim.datetimetz.MONDAY
		plugin.preferences['namespace'] = Path('Calendar')

		for path in (
			'Calendar:2012',
			'Calendar:2012:04:27',
			'Calendar:2012:Week 17',
			'Calendar:2012:04',
		):
			page = notebook.get_page(Path(path))
			lines = template.process(notebook, page)
			text = ''.join(lines)
			#~ print text
			self.assertTrue(not 'Created' in text) # No fall back
			if 'Week' in path:
				days = [l for l in lines if l.startswith('=== ')]
				self.assertEqual(len(days), 7)
开发者ID:gdw2,项目名称:zim,代码行数:25,代码来源:calendar.py


示例4: setupGtkInterface

def setupGtkInterface(test, klass=None):
	'''Setup a new GtkInterface object for testing.
	Will have test notebook, and default preferences.
	@param test: the test that wants to use this ui object
	@param klass: the klass to use, defaults to L{GtkInterface}, but
	could be partially mocked subclass
	'''
	if klass is None:
		klass = zim.gui.GtkInterface

	# start filtering
	filter = FilterNoSuchImageWarning()
	filter.wrap_test(test)

	# flush preferences
	preferences = config_file('preferences.conf')
	preferences.file.remove()

	# create interface object with new notebook
	dirpath = test.get_tmp_name()
	notebook = tests.new_notebook(fakedir=dirpath)
	path = Path('Test:foo:bar')
	ui = klass(notebook=notebook, page=path)

	# finalize plugins
	for plugin in ui.plugins:
		plugin.finalize_ui(ui)

	ui.mainwindow.init_uistate()

	return ui
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:31,代码来源:gui.py


示例5: runTest

	def runTest(self):
		'Test WWW interface'
		config = VirtualConfigManager()
		notebook = tests.new_notebook(fakedir=self.get_tmp_name())
		notebook.index.update()
		interface = WWWInterface(notebook, config=config, template=self.template)
		validator = wsgiref.validate.validator(interface)

		def call(command, path):
			environ = {
				'REQUEST_METHOD': command,
				'SCRIPT_NAME': '',
				'PATH_INFO': path,
				'QUERY_STRING': '',
				'SERVER_NAME': 'localhost',
				'SERVER_PORT': '80',
				'SERVER_PROTOCOL': '1.0'
			}
			rfile = StringIO('')
			wfile = StringIO()
			handler = wsgiref.handlers.SimpleHandler(rfile, wfile, sys.stderr, environ)
			if os.name == 'nt':
				# HACK: on windows we have no file system encoding,
				# but use unicode instead for os API.
				# However wsgiref.validate fails on unicode param
				# in environmnet.
				for k, v in handler.os_environ.items():
					if isinstance(v, unicode):
						handler.os_environ[k] = v.encode('utf-8')

			handler.run(validator)
			#~ print '>>>>\n', wfile.getvalue(), '<<<<'
			return wfile.getvalue()

		# index
		for path in ('/', '/Test/'):
			response = call('HEAD', path)
			self.assertResponseOK(response, expectbody=False)
			response = call('GET', path)
			#~ print '>'*80, '\n', response, '<'*80
			self.assertResponseOK(response)
			self.assertTrue('<li><a href="/Test/foo.html" title="foo" class="page">foo</a>' in response)

		# page
		response = call('GET', '/Test/foo.html')
		self.assertResponseOK(response)
		self.assertTrue('<h1>Foo</h1>' in response)

		# page not found
		with Filter404():
			for path in self.file_not_found_paths:
				response = call('GET', path)
				header, body = self.assertResponseWellFormed(response)
				self.assertEqual(header[0], 'HTTP/1.0 404 Not Found')

		# favicon and other files
		for path in self.file_found_paths:
			response = call('GET', path)
			header, body = self.assertResponseWellFormed(response)
			self.assertEqual(header[0], 'HTTP/1.0 200 OK')
开发者ID:gdw2,项目名称:zim,代码行数:60,代码来源:www.py


示例6: testTaskListTreeView

	def testTaskListTreeView(self):
		klass = PluginManager.get_plugin_class('tasklist')
		plugin = klass()

		notebook = tests.new_notebook()
		plugin.extend(notebook.index)
		index_ext = plugin.get_extension(IndexExtension)
		self.assertIsNotNone(index_ext)

		notebook.index.flush()
		notebook.index.update()

		from zim.plugins.tasklist import TaskListTreeView
		opener = tests.MockObject()
		treeview = TaskListTreeView(index_ext, opener)

		menu = treeview.get_popup()

		# Check these do not cause errors - how to verify state ?
		tests.gtk_activate_menu_item(menu, _("Expand _All"))
		tests.gtk_activate_menu_item(menu, _("_Collapse All"))

		# Copy tasklist -> csv
		from zim.gui.clipboard import Clipboard
		tests.gtk_activate_menu_item(menu, 'gtk-copy')
		text = Clipboard.get_text()
		lines = text.splitlines()
		self.assertTrue(len(lines) > 10)
		self.assertTrue(len(lines[0].split(',')) > 3)
		self.assertFalse(any('<span' in l for l in lines)) # make sure encoding is removed
开发者ID:fabricehong,项目名称:zim-desktop,代码行数:30,代码来源:tasklist.py


示例7: testParseExec

    def testParseExec(self):
        """Test parsing of custom tool Exec strings"""
        # %f for source file as tmp file current page
        # %d for attachment directory
        # %s for real source file (if any)
        # %n for notebook location (file or directory)
        # %D for document root
        # %t for selected text or word under cursor
        # %T for selected text or word under cursor with wiki format

        path = self.get_tmp_name()
        notebook = tests.new_notebook(fakedir=path)
        page = notebook.get_page(Path("Test:Foo"))
        pageview = StubPageView()
        args = (notebook, page, pageview)

        tmpfile = TmpFile("tmp-page-source.txt").path
        dir = notebook.dir

        tool = CustomToolDict()
        tool.update({"Name": "Test", "Description": "Test 1 2 3", "X-Zim-ExecTool": "foo"})
        for cmd, wanted in (
            ("foo %f", ("foo", tmpfile)),
            ("foo %d", ("foo", dir.subdir("Test/Foo").path)),
            ("foo %s", ("foo", "")),  # no file source
            ("foo %n", ("foo", dir.path)),
            ("foo %D", ("foo", "")),  # no document root
            ("foo %t", ("foo", "FooBar")),
            ("foo %T", ("foo", "**FooBar**")),
        ):
            # ~ print '>>>', cmd
            tool["Desktop Entry"]["X-Zim-ExecTool"] = cmd
            self.assertEqual(tool.parse_exec(args), wanted)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:33,代码来源:applications.py


示例8: testTemplate

	def testTemplate(self):
		pluginklass = PluginManager.get_plugin_class('calendar')
		plugin = pluginklass()
		plugin.preferences['namespace'] = Path('Calendar')

		notebook = tests.new_notebook()
		plugin.extend(notebook)

		dumper = get_dumper('wiki')

		zim.datetimetz.FIRST_DAY_OF_WEEK = \
			zim.datetimetz.MONDAY
		for path in (
			Path('Calendar:2012'),
			Path('Calendar:2012:04:27'),
			Path('Calendar:2012:Week 17'),
			Path('Calendar:2012:04'),
		):
			tree = notebook.get_template(path)
			lines = dumper.dump(tree)
			#~ print lines
			self.assertTrue(not 'Created' in ''.join(lines)) # No fall back
			if 'Week' in path.name:
				days = [l for l in lines if l.startswith('=== ')]
				self.assertEqual(len(days), 7)
开发者ID:fabricehong,项目名称:zim-desktop,代码行数:25,代码来源:calendar.py


示例9: setUp

	def setUp(self):
		# Note that in this test our index is not the default index
		# for the notebook. So any assumption from the notebook about
		# the index will be wrong.
		self.index = Index(dbfile=':memory:')
		self.notebook = tests.new_notebook()
		self.index.set_notebook(self.notebook)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:7,代码来源:index.py


示例10: setUp

	def setUp(self):
		self.ui = tests.MockObject()
		self.ui.page = Path('Test')
		self.notebook = tests.new_notebook()
		self.ui.notebook = self.notebook
		self.model = PageTreeStore(self.notebook.index)
		self.treeview = PageTreeView(self.ui, self.model)
		treepath = self.treeview.set_current_page(Path('Test'))
		self.treeview.select_treepath(treepath)
开发者ID:fabricehong,项目名称:zim-desktop,代码行数:9,代码来源:index.py


示例11: testDefaulPlugins

	def testDefaulPlugins(self):
		'''Test loading default plugins'''
		# Note that we use parent interface class here, so plugins
		# will not really attach - just testing loading and prereq
		# checks are OK.
		notebook = tests.new_notebook()
		interface = zim.NotebookInterface(notebook)
		interface.uistate = zim.config.ConfigDict()
		interface.load_plugins()
		self.assertTrue(len(interface.plugins) > 3)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:10,代码来源:plugins.py


示例12: setUp

    def setUp(self):
        path = self.get_tmp_name()
        self.nb = tests.new_notebook(fakedir=path)
        self.assertIsNone(self.nb.profile)

        with FilterFailedToLoadPlugin():
            self.ui = NotebookInterface(self.nb)

        configfile = self.ui.preferences.file
        configfile.file.remove()  # just in case
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:10,代码来源:main.py


示例13: testExport

    def testExport(self):
        """test the export of a wiki page to latex"""
        with LatexLoggingFilter():
            format = get_format("LaTeX")
            testpage = tests.WikiTestData.get("Test:wiki")
            tree = get_format("wiki").Parser().parse(testpage)
            output = format.Dumper(linker=StubLinker()).dump(tree)
            # ~ print '>>>\n' + ''.join(output) + '<<<'
            self.assertTrue("\chapter{Foo Bar}\n" in output)

            # Test template_options.document_type
        input = r"""
[% options.document_type = 'book' -%]
\title{[% page.basename %]}

\begin{document}
\maketitle
\tableofcontents
[% page.body %]
\end{document}
"""
        wanted = r"""
\title{FooBar}

\begin{document}
\maketitle
\tableofcontents
\textbf{foo bar !}



\chapter{Heading 2}

duss


\end{document}
"""

        notebook = tests.new_notebook()
        page = notebook.get_page(Path("FooBar"))
        page.parse(
            "wiki",
            """\
====== Page Heading ======
**foo bar !**

===== Heading 2 =====
duss
""",
        )

        template = Template(input, "latex", linker=StubLinker())
        result = template.process(notebook, page)
        self.assertEqual("".join(result), wanted)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:55,代码来源:formats.py


示例14: runTest

	def runTest(self):
		input = u'''\
Version [% zim.version %]
<title>[% page.title %]</title>
Created [% page.properties['Creation-Date'] %]
<h1>[% notebook.name %]: [% page.name %]</h1>
<h2>[% page.heading %]</h2>
[% options.foo = "bar" %]
[%- page.body -%]
Option: [% options.foo %]
'''
		wantedresult = u'''\
Version %s
<title>Page Heading</title>
Created TODAY
<h1>Unnamed Notebook: FooBar</h1>
<h2>Page Heading</h2>
<p>
<b>foo bar !</b>
</p>
Option: bar
''' % zim.__version__
		notebook = tests.new_notebook()
		page = notebook.get_page(Path('FooBar'))
		page.parse('wiki', '''\
====== Page Heading ======
**foo bar !**
''')
		page.properties['Creation-Date'] = 'TODAY'
		self.assertTrue(len(page.dump('html', linker=StubLinker())) > 0)
		template = Template(input, 'html', linker=StubLinker())
		result = template.process(notebook, page)
		self.assertEqual(''.join(result), wantedresult)
		self.assertEqual(template.template_options['foo'], 'bar')

		# Check new page template
		notebook = tests.new_notebook()
		page = notebook.get_page(Path('Some New None existing page'))
		template = notebook.get_template(page)
		tree = template.process_to_parsetree(notebook, page) # No linker !
		head = tree.find('h').gettext()
		self.assertEqual(head, u'Some New None existing page')
开发者ID:gdw2,项目名称:zim,代码行数:42,代码来源:templates.py


示例15: runTest

	def runTest(self):
		'Test PrintToBrowser plugin'
		pluginklass = PluginManager.get_plugin_class('printtobrowser')
		plugin = pluginklass()

		notebook = tests.new_notebook()
		page = notebook.get_page(Path('Test:foo'))
		file = plugin.print_to_file(notebook, page)
		self.assertTrue(file.exists())
		content = file.read()
		self.assertTrue('<h1>Foo</h1>' in content)
开发者ID:fabricehong,项目名称:zim-desktop,代码行数:11,代码来源:printtobrowser.py


示例16: __init__

	def __init__(self, page=None, fakedir=None):
		tests.MockObject.__init__(self)

		self.tmp_dir = self.create_tmp_dir()

		if page and not isinstance(page, Path):
			self.page = Path(page)
		else:
			self.page = page

		self.mainwindow = None
		self.notebook = tests.new_notebook(fakedir=fakedir)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:12,代码来源:gui.py


示例17: testExport

	def testExport(self):
		'''test the export of a wiki page to latex'''
		with LatexLoggingFilter():
			format = get_format('LaTeX')
			testpage = tests.WikiTestData.get('Test:wiki')
			tree = get_format('wiki').Parser().parse(testpage)
			output = format.Dumper(linker=StubLinker()).dump(tree)
			#~ print '>>>\n' + ''.join(output) + '<<<'
			self.assertTrue('\chapter{Foo Bar}\n' in output)

		# Test template_options.document_type
		input = r'''
[% options.document_type = 'book' -%]
\title{[% page.basename %]}

\begin{document}
\maketitle
\tableofcontents
[% page.body %]
\end{document}
'''
		wanted = r'''
\title{FooBar}

\begin{document}
\maketitle
\tableofcontents
\textbf{foo bar !}



\chapter{Heading 2}

duss


\end{document}
'''

		notebook = tests.new_notebook()
		page = notebook.get_page(Path('FooBar'))
		page.parse('wiki', '''\
====== Page Heading ======
**foo bar !**

===== Heading 2 =====
duss
''')

		template = Template(input, 'latex', linker=StubLinker())
		result = template.process(notebook, page)
		self.assertEqual(''.join(result), wanted)
开发者ID:gdw2,项目名称:zim,代码行数:52,代码来源:formats.py


示例18: testSearchDialog

	def testSearchDialog(self):
		'''Test SearchDialog'''
		from zim.gui.searchdialog import SearchDialog
		self.ui.notebook = tests.new_notebook()
		dialog = SearchDialog(self.ui)
		dialog.query_entry.set_text('Foo')
		dialog.query_entry.activate()
		model = dialog.results_treeview.get_model()
		self.assertTrue(len(model) > 3)

		self.ui.mainwindow = tests.MockObject()
		self.ui.mainwindow.pageview = tests.MockObject()
		col = dialog.results_treeview.get_column(0)
		dialog.results_treeview.row_activated((0,), col)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:14,代码来源:gui.py


示例19: runTest

	def runTest(self):
		notebook = tests.new_notebook()
		page = notebook.get_page(Path('FooBar'))

		page.parse('wiki', '''\
====== Page Heading ======
**foo bar !**
''')
		self.assertTrue(len(page.dump('html', linker=StubLinker())) > 0)
		proxy = PageProxy(Notebook(), page, zim.formats.get_format('html'), StubLinker(), {})
		self.assertEqual(proxy.name, page.name)
		self.assertEqual(proxy.namespace, page.namespace)
		self.assertEqual(proxy.basename, page.basename)
		self.assertTrue(isinstance(proxy.properties, dict))
		self.assertTrue(len(proxy.body) > 0)
开发者ID:Jam71,项目名称:Zim-QDA,代码行数:15,代码来源:templates.py


示例20: testDeletePages

	def testDeletePages(self):
		'''Check deleting a bookmark after deleting a page in the notebook.'''

		notebook = tests.new_notebook()
		ui = MockUI()
		ui.notebook = notebook
		self.uistate['bookmarks'] = list(self.PATHS)

		Bar = BookmarkBar(ui, self.uistate, get_page_func = lambda: '')
		for i, path in enumerate(self.PATHS):
			self.assertTrue(path in Bar.paths)
			notebook.delete_page(Path(path))
			self.assertTrue(path not in Bar.paths)
			self.assertEqual(len(Bar.paths), self.LEN_PATHS - i - 1)
		self.assertEqual(Bar.paths, [])
开发者ID:Pl-M,项目名称:zim-bookmarksbar-plugin,代码行数:15,代码来源:BookmarksBar.py



注:本文中的tests.new_notebook函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.op_fixture函数代码示例发布时间:2022-05-27
下一篇:
Python tests.mocked_response函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap