Exemplo n.º 1
0
	def test_branch(self):
		with replace_module_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: None)):
			self.assertEqual(common.branch(status_colors=False), 'tests')
			self.assertEqual(common.branch(status_colors=True),
					[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
		with replace_module_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: 'D  ')):
			self.assertEqual(common.branch(status_colors=False), 'tests')
			self.assertEqual(common.branch(),
					[{'contents': 'tests', 'highlight_group': ['branch_dirty', 'branch']}])
		with replace_module_attr(common, 'guess', lambda path: None):
			self.assertEqual(common.branch(), None)
Exemplo n.º 2
0
	def test_branch(self):
		pl = Pl()
		segment_info = {'getcwd': os.getcwd}
		with replace_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: None, directory='/tmp/tests')):
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False), 'tests')
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=True),
					[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
		with replace_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: 'D  ', directory='/tmp/tests')):
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False), 'tests')
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=True),
					[{'contents': 'tests', 'highlight_group': ['branch_dirty', 'branch']}])
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info), 'tests')
		with replace_attr(common, 'guess', lambda path: None):
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info), None)
Exemplo n.º 3
0
	def test_branch(self):
		pl = Pl()
		segment_info = {'getcwd': os.getcwd}
		with replace_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: None, directory='/tmp/tests')):
			with replace_attr(common, 'tree_status', lambda repo, pl: None):
				self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
				self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=True),
						[{'contents': 'tests', 'highlight_group': ['branch_clean', 'branch']}])
		with replace_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path), status=lambda: 'D  ', directory='/tmp/tests')):
			with replace_attr(common, 'tree_status', lambda repo, pl: 'D '):
				self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
				self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=True),
						[{'contents': 'tests', 'highlight_group': ['branch_dirty', 'branch']}])
				self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False),
						[{'highlight_group': ['branch'], 'contents': 'tests'}])
		with replace_attr(common, 'guess', lambda path: None):
			self.assertEqual(common.branch(pl=pl, segment_info=segment_info, status_colors=False), None)
Exemplo n.º 4
0
	def test_branch(self):
		with replace_module_attr(common, 'guess', lambda path: Args(branch=lambda: os.path.basename(path))):
			self.assertEqual(common.branch(), 'tests')
		with replace_module_attr(common, 'guess', lambda path: None):
			self.assertEqual(common.branch(), None)