5
from bzrlib.plugins.bzrtools.hunk_selector import (
9
from bzrlib.plugins.bzrtools.errors import NoColor
5
11
class ShelfTests(bzrlib.tests.TestCaseWithTransport):
6
12
ORIGINAL = '\n\nhello test world\n\n'
7
13
MODIFIED = '\n\ngoodbye test world\n\n'
550
556
# Hex and is cracky, so it shouldn't work
551
557
stdout, error = self.run_bzr_captured(['unshelve', '0x00'], retcode=3)
552
558
self.assertTrue("Invalid patch name '0x00'" in error)
560
def test_color_hunk_selector(self):
561
"""Make sure NoColor is raised iff terminal.has_ansi_colors is False"""
562
hs = ShelveHunkSelector([])
563
hs = UnshelveHunkSelector([])
564
from bzrlib.plugins.bzrtools import terminal
565
old_has_ansi_colors = terminal.has_ansi_colors
566
terminal.has_ansi_colors = lambda: False
568
self.assertRaises(NoColor, ShelveHunkSelector, [], True)
569
self.assertRaises(NoColor, UnshelveHunkSelector, [], True)
570
terminal.has_ansi_colors = lambda: True
571
hs = ShelveHunkSelector([], color=True)
572
hs = UnshelveHunkSelector([], color=True)
574
terminal.has_ansi_colors = old_has_ansi_colors
576
def test_no_color(self):
577
"""Ensure --no-color switch can be passed"""
578
self.tree = self.make_branch_and_tree('.')
582
self.tree.add(subdir)
585
self.__create_and_add_test_file()
587
# Modify the test file
588
# write in binary mode because on win32 line-endings should be LF
589
f = file('test_file', 'wb')
590
f.write(self.MODIFIED)
592
stdout, error = self.run_bzr_captured(['shelve', '--all',
594
stdout, error = self.run_bzr_captured(['unshelve', '--all',