file_name stringlengths 3 116 | file_path stringlengths 13 224 | content stringlengths 17 59.1k | language stringclasses 1
value |
|---|---|---|---|
core_test.py | git-cola_git-cola/test/core_test.py | def test_core_decode():
"""Test the core.decode function"""
filename = helper.fixture('unicode.txt')
expect = core.decode(core.encode('unicøde'))
actual = core.read(filename).strip()
assert expect == actual
def test_core_encode():
"""Test the core.encode function"""
filename = helper.fixtur... | Python |
startup_test.py | git-cola_git-cola/test/startup_test.py | def test_get_with_default_repo(app_context):
"""Test BuildItem::get for default repo"""
path = '/home/foo/git-cola'
name = 'git-cola'
mode = startup.ICON_MODE
is_bookmark = True
app_context.cfg.set_repo('cola.defaultrepo', path)
builder = startup.BuildItem(app_context)
actual = builder.g... | Python |
spellcheck_test.py | git-cola_git-cola/test/spellcheck_test.py | def test_spellcheck_generator():
check = spellcheck.NorvigSpellCheck()
assert_spellcheck(check)
def test_spellcheck_unicode():
path = helper.fixture('unicode.txt')
check = spellcheck.NorvigSpellCheck(words=path)
assert_spellcheck(check)
def assert_spellcheck(check):
for word in check.read():
... | Python |
compat_test.py | git-cola_git-cola/test/compat_test.py | def test_setenv():
"""Test the core.decode function"""
key = 'COLA_UNICODE_TEST'
value = '字龍'
compat.setenv(key, value)
assert key in os.environ
assert os.getenv(key)
compat.unsetenv(key)
assert key not in os.environ
assert not os.getenv(key) | Python |
gitcfg_test.py | git-cola_git-cola/test/gitcfg_test.py | def assert_color(context, expect, git_value, key='test', default=None):
"""Helper function for testing color values"""
helper.run_git('config', 'cola.color.%s' % key, git_value)
context.cfg.reset()
actual = context.cfg.color(key, default)
assert expect == actual
def test_string(app_context):
""... | Python |
main_model_test.py | git-cola_git-cola/test/main_model_test.py | @pytest.fixture
def mock_context():
"""Return a Mock context for testing"""
context = Mock()
context.git = git.create()
return context
def test_project(app_context):
"""Test the 'project' attribute."""
project = os.path.basename(core.getcwd())
app_context.model.set_worktree(core.getcwd())
... | Python |
app_test.py | git-cola_git-cola/test/app_test.py | def test_setup_environment():
assert hasattr(app, 'setup_environment')
app.setup_environment()
def test_add_common_arguments():
parser = argparse.ArgumentParser()
assert hasattr(app, 'add_common_arguments')
app.add_common_arguments(parser) | Python |
cmds_test.py | git-cola_git-cola/test/cmds_test.py | def test_Commit_strip_comments():
"""Ensure that commit messages are stripped of comments"""
msg = 'subject\n\n#comment\nbody'
expect = 'subject\n\nbody\n'
actual = cmds.Commit.strip_comments(msg)
assert expect == actual
def test_commit_strip_comments_unicode():
"""Ensure that unicode is preser... | Python |
display_test.py | git-cola_git-cola/test/display_test.py | def test_shorten_paths():
paths = ('/usr/src/git-cola/src', '/usr/src/example/src', '/usr/src/super/lib/src', '/usr/src/super/tools/src', '/usr/src/super/example/src', '/lib/src')
actual = display.shorten_paths(paths)
assert actual[paths[0]] == 'git-cola/src'
assert actual[paths[1]] == 'src/example/src'... | Python |
gitcmds_test.py | git-cola_git-cola/test/gitcmds_test.py | def test_currentbranch(app_context):
"""Test current_branch()."""
assert gitcmds.current_branch(app_context) == 'main'
def test_branch_list_local(app_context):
"""Test branch_list(remote=False)."""
helper.commit_files()
expect = ['main']
actual = gitcmds.branch_list(app_context, remote=False)
... | Python |
gitops_test.py | git-cola_git-cola/test/gitops_test.py | def test_git_commit(app_context):
"""Test running 'git commit' via cola.git"""
helper.write_file('A', 'A')
helper.write_file('B', 'B')
helper.run_git('add', 'A', 'B')
app_context.git.commit(m='initial commit')
log = helper.run_git('-c', 'log.showsignature=false', 'log', '--pretty=oneline')
e... | Python |
branch_test.py | git-cola_git-cola/test/branch_test.py | def test_create_tree_entries():
names = ['abc', 'cat/abc', 'cat/def', 'xyz/xyz']
root = branch.create_tree_entries(names)
expect = 3
actual = len(root.children)
assert expect == actual
abc = root.children[0]
expect = 'abc'
actual = abc.basename
assert expect == actual
expect = 'a... | Python |
resources_test.py | git-cola_git-cola/test/resources_test.py | @patch('cola.resources.compat')
@patch('cola.resources.get_prefix')
def test_command_unix(mock_prefix, mock_compat):
"""Test the behavior of resources.command() on unix platforms"""
mock_compat.WIN32 = False
mock_prefix.return_value = helper.fixture()
expect = helper.fixture('bin', 'bare-cmd')
actua... | Python |
icons_test.py | git-cola_git-cola/test/icons_test.py | def test_from_filename_unicode():
filename = compat.uchr(1024) + '.py'
expect = 'file-code.svg'
actual = icons.basename_from_filename(filename)
assert expect == actual
actual = icons.basename_from_filename(core.encode(filename))
assert expect == actual | Python |
gravatar_test.py | git-cola_git-cola/test/gravatar_test.py | def test_url_for_email_():
email = 'email@example.com'
expect = 'https://gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e?s=64' + '&d=https%3A%2F%2Fgit-cola.github.io%2Fimages%2Fgit-64x64.jpg'
actual = gravatar.Gravatar.url_for_email(email, 64)
assert expect == actual
assert isinstance(actual, u... | Python |
git_test.py | git-cola_git-cola/test/git_test.py | @patch('cola.git.is_git_dir')
def test_find_git_dir_None(is_git_dir):
paths = git.find_git_directory(None)
assert not is_git_dir.called
assert paths.git_dir is None
assert paths.git_file is None
assert paths.worktree is None
@patch('cola.git.is_git_dir')
def test_find_git_dir_empty_string(is_git_di... | Python |
settings_test.py | git-cola_git-cola/test/settings_test.py | @pytest.fixture(autouse=True)
def settings_fixture():
"""Provide Settings that save into a temporary location to all tests"""
filename = helper.tmp_path('settings')
Settings.config_path = filename
yield Settings.read()
if os.path.exists(filename):
os.remove(filename)
def test_gui_save_resto... | Python |
utils_test.py | git-cola_git-cola/test/utils_test.py | def test_basename():
"""Test the utils.basename function."""
assert utils.basename('bar') == 'bar'
assert utils.basename('/bar') == 'bar'
assert utils.basename('/bar ') == 'bar '
assert utils.basename('foo/bar') == 'bar'
assert utils.basename('/foo/bar') == 'bar'
assert utils.basename('foo/f... | Python |
browse_model_test.py | git-cola_git-cola/test/browse_model_test.py | def test_stage_paths_untracked(app_context):
"""Test stage_paths() with an untracked file."""
model = app_context.model
core.makedirs('foo/bar')
helper.touch('foo/bar/baz')
gitcmds.add(app_context, ['foo'])
app_context.model.update_file_status()
assert 'foo/bar/baz' in model.staged
asser... | Python |
dag_test.py | git-cola_git-cola/test/dag_test.py | def __init__(self, app_context, head='HEAD', count=1000):
self.context = app_context
self.params = dag.DAG(head, count)
self.reader = dag.RepoReader(app_context, self.params)
@pytest.fixture
def dag_context(app_context):
"""Provide DAGTestData for use by tests"""
return DAGTestData(app_context)
@p... | Python |
switcher_test.py | git-cola_git-cola/test/switcher_test.py | def test_switcher_item_with_only_key():
"""item text would be key by building item without name"""
key = 'item-key'
actual = switcher.switcher_item(key)
assert actual.key == key
assert actual.text() == key
def test_switcher_item_with_key_name_icon():
"""item text would be name by building item ... | Python |
helper.py | git-cola_git-cola/test/helper.py | def tmp_path(*paths):
"""Returns a path relative to the test/tmp directory"""
dirname = core.decode(os.path.dirname(__file__))
return os.path.join(dirname, 'tmp', *paths)
def fixture(*paths):
dirname = core.decode(os.path.dirname(__file__))
return os.path.join(dirname, 'fixtures', *paths)
def remo... | Python |
i18n_test.py | git-cola_git-cola/test/i18n_test.py | @pytest.fixture(autouse=True)
def i18n_context():
"""Perform cleanup/teardown of the i18n module"""
yield
i18n.uninstall()
def test_translates_noun():
"""Test that strings with @@noun are translated"""
i18n.install('ja_JP')
expect = uchr(12467) + uchr(12511) + uchr(12483) + uchr(12488)
actu... | Python |
stash_model_test.py | git-cola_git-cola/test/stash_model_test.py | def test_stash_info_for_message_without_slash(app_context):
helper.commit_files()
helper.write_file('A', 'change')
helper.run_git('stash', 'save', 'some message')
assert StashModel(app_context).stash_info()[0] == ['stash@{0}: On main: some message']
def test_stash_info_for_message_with_slash(app_contex... | Python |
models_selection_test.py | git-cola_git-cola/test/models_selection_test.py | def test_union():
t = Mock()
t.staged = ['a']
t.unmerged = ['a', 'b']
t.modified = ['b', 'a', 'c']
t.untracked = ['d']
expect = ['a', 'b', 'c', 'd']
actual = selection.union(t)
assert expect == actual | Python |
diffparse_test.py | git-cola_git-cola/test/diffparse_test.py | def __init__(self):
self.parser = diffparse.DiffLines()
fixture_path = helper.fixture('diff.txt')
self.text = core.read(fixture_path)
@pytest.fixture
def difflines_data():
"""Return test data for diffparse.DiffLines tests"""
return DiffLinesTestData()
def test_diff():
fixture_path = helper.fix... | Python |
textwrap_test.py | git-cola_git-cola/test/textwrap_test.py | def __init__(self):
self.tabwidth = 8
self.limit = None
def wrap(self, text, break_on_hyphens=True):
return textwrap.word_wrap(text, self.tabwidth, self.limit, break_on_hyphens=break_on_hyphens)
@pytest.fixture
def wordwrap():
"""Provide default word wrap options for tests"""
return WordWrapDefaul... | Python |
_activate_cola.py | git-cola_git-cola/bin/_activate_cola.py | def activate():
"""Activate the cola development environment"""
initialize_python()
initialize_version()
def get_prefix():
"""Return the path to the source tree"""
realpath = os.path.abspath(os.path.realpath(__file__))
return os.path.dirname(os.path.dirname(realpath))
def initialize_python():
... | Python |
sphinxtogithub.py | git-cola_git-cola/extras/sphinxtogithub/sphinxtogithub.py | def stdout(msg):
sys.stdout.write(msg + '\n')
def __init__(self, is_dir, list_dir, walk, rmtree):
self.is_dir = is_dir
self.list_dir = list_dir
self.walk = walk
self.rmtree = rmtree
def __init__(self, open_, path_join, move, exists):
self.open_ = open_
self.path_join = path_join
self.m... | Python |
conf.py | git-cola_git-cola/docs/conf.py | def _overwrite_pygments_css(app, exception):
"""Replacement for furo._overwrite_pygments_css to handle sphinxtogithub"""
if exception is not None:
return
assert app.builder
with open(os.path.join(app.builder.outdir, 'static', 'pygments.css'), 'w', encoding='utf-8') as f:
f.write(furo.get... | Python |
run-pynsist.sh | git-cola_git-cola/contrib/win32/run-pynsist.sh | <Error parsing source code | Python |
difftool.py | git-cola_git-cola/cola/difftool.py | @staticmethod
def name():
return N_('Launch Diff Tool')
def do(self):
s = self.selection.selection()
if s.unmerged:
paths = s.unmerged
if utils.is_win32():
core.fork(['git', 'mergetool', '--no-prompt', '--'] + paths)
else:
cfg = self.cfg
cmd = cfg... | Python |
resources.py | git-cola_git-cola/cola/resources.py | def get_prefix():
"""Return the installation prefix"""
return _prefix
def prefix(*args):
"""Return a path relative to cola's installation prefix"""
return os.path.join(get_prefix(), *args)
def sibling_bindir(*args):
"""Return a command sibling to sys.argv[0]"""
relative_bindir = os.path.dirnam... | Python |
__main__.py | git-cola_git-cola/cola/__main__.py | def run():
"""Start the command-line interface."""
main.main() | Python |
interaction.py | git-cola_git-cola/cola/interaction.py | @classmethod
def command(cls, title, cmd, status, out, err):
"""Log a command and display error messages on failure"""
cls.log_status(status, out, err)
if status != 0:
cls.command_error(title, cmd, status, out, err)
@classmethod
def command_error(cls, title, cmd, status, out, err):
"""Display a... | Python |
settings.py | git-cola_git-cola/cola/settings.py | def mkdict(obj):
"""Transform None and non-dicts into dicts"""
if isinstance(obj, dict):
value = obj
else:
value = {}
return value
def mklist(obj):
"""Transform None and non-lists into lists"""
if isinstance(obj, list):
value = obj
elif isinstance(obj, tuple):
... | Python |
spellcheck.py | git-cola_git-cola/cola/spellcheck.py | def train(features, model):
for f in features:
model[f] += 1
return model
def edits1(word):
splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
deletes = [a + b[1:] for a, b in splits if b]
transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b) > 1]
replaces = [a +... | Python |
guicmds.py | git-cola_git-cola/cola/guicmds.py | def delete_branch(context):
"""Launch the 'Delete Branch' dialog."""
icon = icons.discard()
branch = choose_branch(context, N_('Delete Branch'), N_('Delete'), icon=icon)
if not branch:
return
cmds.do(cmds.DeleteBranch, context, branch)
def delete_remote_branch(context):
"""Launch the 'D... | Python |
dag.py | git-cola_git-cola/cola/dag.py | def main(argv=None):
"""Run git-dag"""
app.initialize()
args = parse_args(argv=argv)
return args.func(args)
def shortcut_launch():
"""Run git-dag from a Windows shortcut"""
return main(argv=['--prompt'])
def parse_args(argv=None):
"""Parse command-line arguments"""
if argv is None:
... | Python |
git.py | git-cola_git-cola/cola/git.py | def dashify(value):
return value.replace('_', '-')
def is_git_dir(git_dir):
"""From git's setup.c:is_git_directory()."""
result = False
if git_dir:
headref = join(git_dir, 'HEAD')
if core.isdir(git_dir) and (core.isdir(join(git_dir, 'objects')) and core.isdir(join(git_dir, 'refs'))) or ... | Python |
display.py | git-cola_git-cola/cola/display.py | def shorten_paths(source_paths):
"""Shorten a sequence of paths into unique strings for display"""
result = {}
count = 0
conflicts = list(source_paths)
in_conflict = True
while in_conflict:
count += 1
suffixes = collections.defaultdict(list)
for path in conflicts:
... | Python |
app.py | git-cola_git-cola/cola/app.py | def setup_environment():
"""Set environment variables to control git's behavior"""
random.seed(hash(time.time()))
signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.argv[0] = sys_argv0 = os.path.abspath(sys.argv[0])
os.environ.setdefault('DISPLAY', ':0')
if not core.getenv('SHELL', ''):
fo... | Python |
i18n.py | git-cola_git-cola/cola/i18n.py | def gettext(self, value):
return value
@classmethod
def reset(cls):
cls.translation = NullTranslation()
@classmethod
def update(cls, lang):
cls.translation = Translation(lang)
@classmethod
def gettext(cls, value):
"""Return a translated value"""
return cls.translation.gettext(value)
def __init__... | Python |
hotkeys.py | git-cola_git-cola/cola/hotkeys.py | def hotkey(*seq):
return QKeySequence(*seq) | Python |
utils.py | git-cola_git-cola/cola/utils.py | def asint(obj, default=0):
"""Make any value into an int, even if the cast fails"""
try:
value = int(obj)
except (TypeError, ValueError):
value = default
return value
def clamp(value, low, high):
"""Clamp a value to the specified range"""
return min(high, max(low, value))
def e... | Python |
core.py | git-cola_git-cola/cola/core.py | def __new__(cls, string, encoding):
if isinstance(string, UStr):
if encoding != string.encoding:
raise ValueError(f'Encoding conflict: {string.encoding} vs. {encoding}')
string = ustr(string)
obj = ustr.__new__(cls, string)
obj.encoding = encoding
return obj
def decode_maybe... | Python |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3