From b3bc8431554c8746bf8eef21237d15df6e2d5356 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 28 Sep 2011 21:19:29 +0200 Subject: removed tests. (half of them are outdated) To get them back, you can always simply revert this commit. --- Makefile | 10 +- test/all_benchmarks.py | 56 ---- test/all_tests.py | 37 --- test/bm_human_readable.py | 51 ---- test/bm_loader.py | 174 ------------- test/tc_ansi.py | 40 --- test/tc_bookmarks.py | 92 ------- test/tc_colorscheme.py | 53 ---- test/tc_direction.py | 92 ------- test/tc_directory.py | 124 --------- test/tc_displayable.py | 167 ------------ test/tc_ext.py | 150 ----------- test/tc_history.py | 82 ------ test/tc_human_readable.py | 51 ---- test/tc_keyapi.py | 45 ---- test/tc_loader.py | 79 ------ test/tc_newkeys.py | 620 -------------------------------------------- test/tc_relative_symlink.py | 47 ---- test/tc_signal.py | 139 ---------- test/tc_ui.py | 69 ----- test/tc_utfwidth.py | 46 ---- test/testdir/largefile.txt | 1 - test/testdir/symlink | 1 - test/testdir/textfile.txt | 4 - test/testdir/zerobytes | 0 test/testlib.py | 43 --- 26 files changed, 1 insertion(+), 2272 deletions(-) delete mode 100755 test/all_benchmarks.py delete mode 100755 test/all_tests.py delete mode 100644 test/bm_human_readable.py delete mode 100644 test/bm_loader.py delete mode 100644 test/tc_ansi.py delete mode 100644 test/tc_bookmarks.py delete mode 100644 test/tc_colorscheme.py delete mode 100644 test/tc_direction.py delete mode 100644 test/tc_directory.py delete mode 100644 test/tc_displayable.py delete mode 100644 test/tc_ext.py delete mode 100644 test/tc_history.py delete mode 100644 test/tc_human_readable.py delete mode 100644 test/tc_keyapi.py delete mode 100644 test/tc_loader.py delete mode 100644 test/tc_newkeys.py delete mode 100644 test/tc_relative_symlink.py delete mode 100644 test/tc_signal.py delete mode 100644 test/tc_ui.py delete mode 100644 test/tc_utfwidth.py delete mode 100644 test/testdir/largefile.txt delete mode 120000 test/testdir/symlink delete mode 100644 test/testdir/textfile.txt delete mode 100644 test/testdir/zerobytes delete mode 100644 test/testlib.py diff --git a/Makefile b/Makefile index ed100a8e..77fad740 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,6 @@ SETUPOPTS ?= '--record=install_log.txt' DOCDIR ?= doc/pydoc DESTDIR ?= / PYOPTIMIZE ?= 1 -BMCOUNT ?= 5 # how often to run the benchmarks? CWD = $(shell pwd) @@ -43,7 +42,6 @@ help: @echo 'make clean: Remove the compiled files (*.pyc, *.pyo)' @echo 'make cleandoc: Remove the pydoc documentation' @echo 'make snapshot: Create a tar.gz of the current git revision' - @echo 'make test: Run all unittests.' install: $(PYTHON) setup.py install $(SETUPOPTS) \ @@ -73,13 +71,7 @@ manhtml: cleandoc: test -d $(DOCDIR) && rm -f -- $(DOCDIR)/*.html || true -test: - @$(PYTHON) test/all_tests.py 1 - -bm: - @$(PYTHON) test/all_benchmarks.py $(BMCOUNT) - snapshot: git archive --prefix='$(NAME)-$(VERSION)/' --format=tar HEAD | gzip > $(SNAPSHOT_NAME) -.PHONY: default options compile clean doc cleandoc test bm snapshot install man +.PHONY: default options compile clean doc cleandoc snapshot install man diff --git a/test/all_benchmarks.py b/test/all_benchmarks.py deleted file mode 100755 index a3612701..00000000 --- a/test/all_benchmarks.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Run all the benchmarks inside this directory. -Usage: ./all_benchmarks.py [count] [regexp-filters...] -""" - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import re -import time - -if __name__ == '__main__': - count = int(sys.argv[1]) if len(sys.argv) > 1 else 10 - regexes = [re.compile(fltr) for fltr in sys.argv[2:]] - modules = (fname[:-3] for fname in os.listdir(sys.path[0]) \ - if fname[:3] == 'bm_' and fname[-3:] == '.py') - - def run_benchmark(cls, methodname): - full_method_name = "{0}.{1}".format(cls.__name__, methodname) - if all(re.search(full_method_name) for re in regexes): - method = getattr(cls(), methodname) - t1 = time.time() - try: - method(count) - except: - print("{0} failed!".format(full_method_name)) - raise - else: - t2 = time.time() - print("{0:60}: {1:10}s".format(full_method_name, t2 - t1)) - - for val in [__import__(module) for module in modules]: - for cls in vars(val).values(): - if type(cls) == type: - for methodname in vars(cls): - if methodname.startswith('bm_'): - run_benchmark(cls, methodname) diff --git a/test/all_tests.py b/test/all_tests.py deleted file mode 100755 index 0c184df5..00000000 --- a/test/all_tests.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" -Run all the tests inside this directory as a test suite. -Usage: ./all_tests.py [verbosity] -""" - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest - -if __name__ == '__main__': - verbosity = int(sys.argv[1]) if len(sys.argv) > 1 else 1 - tests = (fname[:-3] for fname in os.listdir(sys.path[0]) \ - if fname[:3] == 'tc_' and fname[-3:] == '.py') - suite = unittest.TestLoader().loadTestsFromNames(tests) - result = unittest.TextTestRunner(verbosity=verbosity).run(suite) - if len(result.errors + result.failures) > 0: - sys.exit(1) diff --git a/test/bm_human_readable.py b/test/bm_human_readable.py deleted file mode 100644 index ef400774..00000000 --- a/test/bm_human_readable.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from ranger.ext.human_readable import * - -# The version before 2010/06/24: -import math -UNITS = 'BKMGTP' -MAX_EXPONENT = len(UNITS) - 1 -def human_readable_old(byte, seperator=' '): - if not byte: - return '0' - - exponent = int(math.log(byte, 2) / 10) - flt = round(float(byte) / (1 << (10 * exponent)), 2) - - if exponent > MAX_EXPONENT: - return '>9000' # off scale - - if int(flt) == flt: - return '%.0f%s%s' % (flt, seperator, UNITS[exponent]) - - else: - return '%.2f%s%s' % (flt, seperator, UNITS[exponent]) - -class benchmark_human_readable(object): - def bm_current(self, n): - for i in range(n): - human_readable((128 * i) % 2**50) - - def bm_old(self, n): - for i in range(n): - human_readable_old((128 * i) % 2**50) diff --git a/test/bm_loader.py b/test/bm_loader.py deleted file mode 100644 index 552954a7..00000000 --- a/test/bm_loader.py +++ /dev/null @@ -1,174 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from ranger.core.loader import Loader -from ranger.fsobject import Directory, File -from ranger.ext.openstruct import OpenStruct -import os.path -from ranger.shared import FileManagerAware, SettingsAware -from testlib import Fake -from os.path import realpath, join, dirname -from subprocess import Popen, PIPE -TESTDIR = realpath(join(dirname(__file__), '/usr/include')) - -def skip(x): - return - -def raw_load_content(self): - """ - The method which is used in a Directory object to load stuff. - Keep this up to date! - """ - - from os.path import join, isdir, basename - from os import listdir - import ranger.ext.mount_path - - self.loading = True - self.load_if_outdated() - - try: - if self.exists and self.runnable: - # 0.003s: - self.mount_path = ranger.ext.mount_path.mount_path(self.path) - - # 0.1s: - filenames = [] - for fname in listdir(self.path): - if not self.settings.show_hidden: - hfilter = self.settings.hidden_filter - if hfilter: - if isinstance(hfilter, str) and hfilter in fname: - continue - if hasattr(hfilter, 'search') and \ - hfilter.search(fname): - continue - if isinstance(self.filter, str) and self.filter \ - and self.filter not in fname: - continue - filenames.append(join(self.path, fname)) - # --- - - self.load_content_mtime = os.stat(self.path).st_mtime - - marked_paths = [obj.path for obj in self.marked_items] - - # 2.85s: - files = [] - for name in filenames: - if isdir(name): - try: - item = self.fm.env.get_directory(name) - except: - item = Directory(name) - else: - item = File(name) - item.load_if_outdated() - files.append(item) - - # 0.2s - self.disk_usage = sum(f.size for f in files if f.is_file) - - self.scroll_offset = 0 - self.filenames = filenames - self.files = files - - self._clear_marked_items() - for item in self.files: - if item.path in marked_paths: - self.mark_item(item, True) - else: - self.mark_item(item, False) - - self.sort() - - if len(self.files) > 0: - if self.pointed_obj is not None: - self.sync_index() - else: - self.move(to=0) - else: - self.filenames = None - self.files = None - - self.cycle_list = None - self.content_loaded = True - self.determine_infostring() - self.correct_pointer() - - finally: - self.loading = False - - -class benchmark_load(object): - def __init__(self): - self.loader = Loader() - fm = OpenStruct(loader=self.loader) - SettingsAware.settings = Fake() - FileManagerAware.fm = fm - self.dir = Directory(TESTDIR) - - def bm_run(self, n): - for _ in range(n): - self.dir.load_content(schedule=True) - while self.loader.has_work(): - self.loader.work() - - -@skip -class benchmark_raw_load(object): - def __init__(self): - SettingsAware.settings = Fake() - self.dir = Directory(TESTDIR) - - def bm_run(self, n): - generator = self.dir.load_bit_by_bit() - for _ in range(n): - raw_load_content(self.dir) - -def bm_loader(n): - """Do some random calculation""" - tloader = benchmark_load(N) - traw = benchmark_raw_load(N) - -class benchmark_load_varieties(object): - def bm_ls(self, n): - for _ in range(n): - Popen(["ls", '-l', TESTDIR], stdout=open(os.devnull, 'w')).wait() - - def bm_os_listdir_stat(self, n): - for _ in range(n): - for f in os.listdir(TESTDIR): - path = os.path.join(TESTDIR, f) - os.stat(path) - - def bm_os_listdir(self, n): - for _ in range(n): - for f in os.listdir(TESTDIR): - path = os.path.join(TESTDIR, f) - - def bm_os_listdir_stat_listdir(self, n): - for _ in range(n): - for f in os.listdir(TESTDIR): - path = os.path.join(TESTDIR, f) - os.stat(path) - if os.path.isdir(path): - os.listdir(path) diff --git a/test/tc_ansi.py b/test/tc_ansi.py deleted file mode 100644 index 0a6ad8b1..00000000 --- a/test/tc_ansi.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2010 David Barnett -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -if __name__ == '__main__': from __init__ import init; init() - -import unittest -from ranger.gui import ansi - -class TestDisplayable(unittest.TestCase): - def test_char_len(self): - ansi_string = "X" - self.assertEqual(ansi.char_len(ansi_string), 1) - - def test_char_len2(self): - ansi_string = "XY" - self.assertEqual(ansi.char_len(ansi_string), 2) - - def test_char_len3(self): - ansi_string = "XY" - self.assertEqual(ansi.char_len(ansi_string), 2) - - def test_char_slice(self): - ansi_string = "XY" - expected = "X" - self.assertEqual(ansi.char_slice(ansi_string, 0, 1), expected) - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_bookmarks.py b/test/tc_bookmarks.py deleted file mode 100644 index 59435f06..00000000 --- a/test/tc_bookmarks.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from os.path import realpath, join, dirname -import unittest -import os -import time - -from ranger.container.bookmarks import Bookmarks - -TESTDIR = realpath(join(dirname(__file__), 'testdir')) -BMFILE = join(TESTDIR, 'bookmarks') - -class TestDisplayable(unittest.TestCase): - def setUp(self): - try: - os.remove(BMFILE) - except: - pass - - def tearDown(self): - try: - os.remove(BMFILE) - except: - pass - - def test_adding_bookmarks(self): - bm = Bookmarks(BMFILE, str, autosave=False) - bm.load() - bm['a'] = 'fooo' - self.assertEqual(bm['a'], 'fooo') - - def test_sharing_bookmarks_between_instances(self): - bm = Bookmarks(BMFILE, str, autosave=True) - bm2 = Bookmarks(BMFILE, str, autosave=True) - - bm.load() - bm2.load() - bm['a'] = 'fooo' - self.assertRaises(KeyError, bm2.__getitem__, 'a') - - bm.save() - bm2.load() - self.assertEqual(bm['a'], bm2['a']) - - bm2['a'] = 'bar' - - bm.save() - bm2.save() - bm.load() - bm2.load() - - self.assertEqual(bm['a'], bm2['a']) - - def test_messing_around(self): - bm = Bookmarks(BMFILE, str, autosave=False) - bm2 = Bookmarks(BMFILE, str, autosave=False) - - bm.load() - bm['a'] = 'car' - - bm2.load() - self.assertRaises(KeyError, bm2.__getitem__, 'a') - - bm2.save() - bm.update() - bm.save() - bm.load() - bm2.load() - - self.assertEqual(bm['a'], bm2['a']) - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_colorscheme.py b/test/tc_colorscheme.py deleted file mode 100644 index eefb1e4f..00000000 --- a/test/tc_colorscheme.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from unittest import TestCase, main -import random -import ranger.colorschemes -from ranger.gui.colorscheme import ColorScheme -from ranger.gui.context import CONTEXT_KEYS - -class Test(TestCase): - def setUp(self): - import random - import curses - curses.COLORS = 88 - schemes = [] - for key, mod in vars(ranger.colorschemes).items(): - if type(mod) == type(random): - for key, var in vars(mod).items(): - if type(var) == type and issubclass(var, ColorScheme) \ - and var != ColorScheme: - schemes.append(var) - self.schemes = set(schemes) - - def test_colorschemes(self): - def test(scheme): - scheme.get() # test with no arguments - - for i in range(300): # test with a bunch of random (valid) arguments - sample = random.sample(CONTEXT_KEYS, random.randint(2, 9)) - scheme.get(*sample) - - for scheme in self.schemes: - test(scheme()) - -if __name__ == '__main__': main() diff --git a/test/tc_direction.py b/test/tc_direction.py deleted file mode 100644 index 16c26dab..00000000 --- a/test/tc_direction.py +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -from ranger.ext.direction import Direction -from ranger.ext.openstruct import OpenStruct - -class TestDirections(unittest.TestCase): - def test_symmetry(self): - d1 = Direction(right=4, down=7, relative=True) - d2 = Direction(left=-4, up=-7, absolute=False) - - def subtest(d): - self.assertEqual(4, d.right()) - self.assertEqual(7, d.down()) - self.assertEqual(-4, d.left()) - self.assertEqual(-7, d.up()) - self.assertEqual(True, d.relative()) - self.assertEqual(False, d.absolute()) - - self.assertTrue(d.horizontal()) - self.assertTrue(d.vertical()) - - subtest(d1) - subtest(d2) - - def test_conflicts(self): - d3 = Direction(right=5, left=2, up=3, down=6, - absolute=True, relative=True) - self.assertEqual(d3.right(), -d3.left()) - self.assertEqual(d3.left(), -d3.right()) - self.assertEqual(d3.up(), -d3.down()) - self.assertEqual(d3.down(), -d3.up()) - self.assertEqual(d3.absolute(), not d3.relative()) - self.assertEqual(d3.relative(), not d3.absolute()) - - def test_copy(self): - d = Direction(right=5) - c = d.copy() - self.assertEqual(c.right(), d.right()) - d['right'] += 3 - self.assertNotEqual(c.right(), d.right()) - c['right'] += 3 - self.assertEqual(c.right(), d.right()) - - self.assertFalse(d.vertical()) - self.assertTrue(d.horizontal()) - -# Doesn't work in python2? -# def test_duck_typing(self): -# dct = dict(right=7, down=-3) -# self.assertEqual(-7, Direction.left(dct)) -# self.assertEqual(3, Direction.up(dct)) - - def test_move(self): - d = Direction(pages=True) - self.assertEqual(3, d.move(direction=3)) - self.assertEqual(5, d.move(direction=3, current=2)) - self.assertEqual(15, d.move(direction=3, pagesize=5)) - self.assertEqual(9, d.move(direction=3, pagesize=5, maximum=10)) - self.assertEqual(18, d.move(direction=9, override=2)) - d2 = Direction(absolute=True) - self.assertEqual(5, d2.move(direction=9, override=5)) - - def test_select(self): - d = Direction(down=3) - lst = list(range(100)) - self.assertEqual((6, [3,4,5,6]), d.select(current=3, pagesize=10, override=None, lst=lst)) - d = Direction(down=3, pages=True) - self.assertEqual((9, [3,4,5,6,7,8,9]), d.select(current=3, pagesize=2, override=None, lst=lst)) - -if __name__ == '__main__': - unittest.main() - diff --git a/test/tc_directory.py b/test/tc_directory.py deleted file mode 100644 index a43ac89d..00000000 --- a/test/tc_directory.py +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from os.path import realpath, join, dirname - -from ranger import fsobject -from ranger.fsobject.file import File -from ranger.fsobject.directory import Directory -from ranger.core.shared import SettingsAware - -SettingsAware._setup() - -TESTDIR = realpath(join(dirname(__file__), 'testdir')) -TESTFILE = join(TESTDIR, 'testfile5234148') -NONEXISTANT_DIR = join(TESTDIR, 'nonexistant') - -import unittest -class Test1(unittest.TestCase): - def test_initial_condition(self): - # Check for the expected initial condition - dir = Directory(TESTDIR) - - self.assertEqual(dir.path, TESTDIR) - self.assertFalse(dir.content_loaded) - self.assertEqual(dir.filenames, None) - self.assertEqual(dir.files, None) - if not sys.flags.optimize: # asserts are ignored with python -O - self.assertRaises(AssertionError, len, dir) - - def test_after_content_loaded(self): - import os - # Check whether the directory has the correct list of filenames. - dir = Directory(TESTDIR) - dir.load_content(schedule=False) - - self.assertTrue(dir.exists) - self.assertEqual(type(dir.filenames), list) - - # Get the filenames you expect it to have and sort both before - # comparing. I don't expect any order after only loading the filenames. - assumed_filenames = os.listdir(TESTDIR) - assumed_filenames = list(map(lambda str: os.path.join(TESTDIR, str), - assumed_filenames)) - assumed_filenames.sort() - dir.filenames.sort() - - self.assertTrue(len(dir) > 0) - self.assertEqual(dir.filenames, assumed_filenames) - - # build a file object for each file in the list assumed_filenames - # and find exactly one equivalent in dir.files - for name in assumed_filenames: - f = File(name) - f.load() - for dirfile in dir.files: - if (f.path == dirfile.path and f.stat == dirfile.stat): - break - else: - self.fail("couldn't find file {0}".format(name)) - - def test_nonexistant_dir(self): - dir = Directory(NONEXISTANT_DIR) - dir.load_content(schedule=False) - - self.assertTrue(dir.content_loaded) - self.assertFalse(dir.exists) - self.assertFalse(dir.accessible) - self.assertEqual(dir.filenames, None) - if not sys.flags.optimize: # asserts are ignored with python -O - self.assertRaises(AssertionError, len, dir) - - def test_load_if_outdated(self): - import os - import time - # modify the directory. If the time between the last modification - # was within the filesystems resolution of mtime, we should have a reload - - def modify_dir(): - open(TESTFILE, 'w').close() - os.unlink(TESTFILE) - - def mtime(): - return os.stat(TESTDIR).st_mtime - - dir = Directory(TESTDIR) - dir.load() - - # If the modification happens to be in the same second as the - # last modification, it will result in mtime having the same - # integer value. So we wait until the resolution is exceeded - # and mtime differs. - old_mtime = mtime() - for i in range(50): - modify_dir() - if old_mtime != mtime(): break - time.sleep(0.1) - else: - # fail after 5 seconds of trying - self.fail( - "Cannot perform test: mtime of TESTDIR is not being updated.") - - self.assertTrue(dir.load_if_outdated()) - -if __name__ == '__main__': - unittest.main() - diff --git a/test/tc_displayable.py b/test/tc_displayable.py deleted file mode 100644 index 72e0507d..00000000 --- a/test/tc_displayable.py +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -import curses -from random import randint - -from ranger.gui.displayable import Displayable, DisplayableContainer -from testlib import Fake, OK, raise_ok, TODO - -class TestWithFakeCurses(unittest.TestCase): - def setUp(self): - self.win = Fake() - self.fm = Fake() - self.env = Fake() - self.settings = Fake() - self.initdict = {'win': self.win, 'settings': self.settings, - 'fm': self.fm, 'env': self.env} - - self.disp = Displayable(**self.initdict) - self.disc = DisplayableContainer(**self.initdict) - self.disc.add_child(self.disp) - - hei, wid = 100, 100 - self.env.termsize = (hei, wid) - - def tearDown(self): - self.disp.destroy() - self.disc.destroy() - - def test_colorscheme(self): - # Using a color method implies change of window attributes - disp = self.disp - - disp.win.chgat = raise_ok - disp.win.attrset = raise_ok - - self.assertRaises(OK, disp.color, 'a', 'b') - self.assertRaises(OK, disp.color_at, 0, 0, 0, 'a', 'b') - self.assertRaises(OK, disp.color_reset) - - def test_focused_object(self): - d1 = Displayable(**self.initdict) - d2 = DisplayableContainer(**self.initdict) - for obj in (Displayable(**self.initdict) for x in range(5)): - d2.add_child(obj) - d3 = DisplayableContainer(**self.initdict) - for obj in (Displayable(**self.initdict) for x in range(5)): - d3.add_child(obj) - - for obj in (d1, d2, d3): - self.disc.add_child(obj) - - d3.container[3].focused = True - - self.assertEqual(self.disc._get_focused_obj(), d3.container[3]) - - d3.container[3].focused = False - d2.container[0].focused = True - - self.assertEqual(self.disc._get_focused_obj(), d2.container[0]) - -gWin = None - -class TestDisplayableWithCurses(unittest.TestCase): - def setUp(self): - global gWin - if not gWin: - gWin = curses.initscr() - self.win = gWin - curses.cbreak() - curses.noecho() - curses.start_color() - curses.use_default_colors() - - self.fm = Fake() - self.env = Fake() - self.settings = Fake() - self.initdict = {'win': self.win, 'settings': self.settings, - 'fm': self.fm, 'env': self.env} - self.disp = Displayable(**self.initdict) - self.disc = DisplayableContainer(**self.initdict) - self.disc.add_child(self.disp) - - self.env.termsize = self.win.getmaxyx() - - def tearDown(self): - self.disp.destroy() - curses.nocbreak() - curses.echo() - curses.endwin() - - @TODO - def test_boundaries(self): - disp = self.disp - hei, wid = self.env.termsize - - self.assertRaises(ValueError, disp.resize, 0, 0, hei + 1, wid) - self.assertRaises(ValueError, disp.resize, 0, 0, hei, wid + 1) - self.assertRaises(ValueError, disp.resize, -1, 0, hei, wid) - self.assertRaises(ValueError, disp.resize, 0, -1, hei, wid) - - for i in range(1000): - box = [int(randint(0, hei) * 0.2), int(randint(0, wid) * 0.2)] - box.append(randint(0, hei - box[0])) - box.append(randint(0, wid - box[1])) - - def in_box(y, x): - return (y >= box[1] and y < box[1] + box[3]) and \ - (x >= box[0] and x < box[0] + box[2]) - - disp.resize(*box) - self.assertEqual(box, [disp.y, disp.x, disp.hei, disp.wid], - "Resizing failed for some reason on loop " + str(i)) - - for y, x in zip(range(10), range(10)): - is_in_box = in_box(y, x) - - point1 = (y, x) - self.assertEqual(is_in_box, point1 in disp) - - point2 = Fake() - point2.x = x - point2.y = y - self.assertEqual(is_in_box, point2 in disp) - - def test_click(self): - self.disp.click = raise_ok - - hei, wid = self.env.termsize - - for i in range(50): - winwid = randint(2, wid-1) - winhei = randint(2, hei-1) - self.disc.resize(0, 0, hei, wid) - self.disp.resize(0, 0, winhei, winwid) - fakepos = Fake() - - fakepos.x = winwid - 2 - fakepos.y = winhei - 2 - self.assertRaises(OK, self.disc.click, fakepos) - - fakepos.x = winwid - fakepos.y = winhei - self.disc.click(fakepos) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_ext.py b/test/tc_ext.py deleted file mode 100644 index 495591a1..00000000 --- a/test/tc_ext.py +++ /dev/null @@ -1,150 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -from collections import deque - -from ranger.ext.iter_tools import * - -class TestCases(unittest.TestCase): - def test_flatten(self): - def f(x): - return list(flatten(x)) - - self.assertEqual( - [1,2,3,4,5], - f([1,2,3,4,5])) - self.assertEqual( - [1,2,3,4,5], - f([1,[2,3],4,5])) - self.assertEqual( - [1,2,3,4,5], - f([[1,[2,3]],4,5])) - self.assertEqual( - [], - f([[[[]]]])) - self.assertEqual( - ['a', 'b', 'fskldfjl'], - f(['a', ('b', 'fskldfjl')])) - self.assertEqual( - ['a', 'b', 'fskldfjl'], - f(['a', deque(['b', 'fskldfjl'])])) - self.assertEqual( - set([3.5, 4.3, 5.2, 6.0]), - set(f([6.0, set((3.5, 4.3)), (5.2, )]))) - - def test_unique(self): - def u(x): - return list(unique(x)) - - self.assertEqual( - [1,2,3], - u([1,2,3])) - self.assertEqual( - [1,2,3], - u([1,2,3,2,1])) - self.assertEqual( - [1,2,3], - u([1,2,3,1,2,3,2,2,3,1,2,3,1,2,3,2,3,2,1])) - self.assertEqual( - [1,[2,3]], - u([1,[2,3],1,[2,3],[2,3],1,[2,3],1,[2,3],[2,3],1])) - - def test_unique_keeps_type(self): - def u(x): - return unique(x) - - self.assertEqual( - [1,2,3], - u([1,2,3,1])) - self.assertEqual( - (1,2,3), - u((1,2,3,1))) - self.assertEqual( - set((1,2,3)), - u(set((1,2,3,1)))) - self.assertEqual( - deque((1,2,3)), - u(deque((1,2,3,1)))) - - def test_mount_path(self): - # assuming ismount() is used - - def my_ismount(path): - depth = path.count('/') - if path.startswith('/media'): - return depth == 0 or depth == 2 - return depth <= 1 - - from ranger.ext import mount_path - original_ismount = mount_path.ismount - mount_path.ismount = my_ismount - try: - mp = mount_path.mount_path - - self.assertEqual('/home', mp('/home/hut/porn/bondage')) - self.assertEqual('/', mp('/')) - self.assertEqual('/media/sdb1', mp('/media/sdb1/foo/bar')) - self.assertEqual('/media/sdc2', mp('/media/sdc2/a/b/c/d/e')) - finally: - mount_path.ismount = original_ismount - - # TODO: links are not tested but I don't see how its possible - # without messing around with mounts. - # self.assertEqual('/media/foo', - # mount_path('/media/bar/some_link_to_a_foo_subdirectory')) - - def test_openstruct(self): - from ranger.ext.openstruct import OpenStruct - from random import randint, choice - from string import ascii_letters - - os = OpenStruct(a='a') - self.assertEqual(os.a, 'a') - self.assertRaises(AttributeError, getattr, os, 'b') - - dictionary = {'foo': 'bar', 'zoo': 'zar'} - os = OpenStruct(dictionary) - self.assertEqual(os.foo, 'bar') - self.assertEqual(os.zoo, 'zar') - self.assertRaises(AttributeError, getattr, os, 'sdklfj') - - for i in range(100): - attr_name = ''.join(choice(ascii_letters) \ - for x in range(randint(3,9))) - value = randint(100,999) - if not attr_name in os: - self.assertRaises(AttributeError, getattr, os, attr_name) - setattr(os, attr_name, value) - value2 = randint(100,999) - setattr(os, attr_name, value2) - self.assertEqual(value2, getattr(os, attr_name)) - - def test_shell_escape(self): - from ranger.ext.shell_escape import shell_escape, shell_quote - self.assertEqual(r"'luigi'\''s pizza'", shell_quote("luigi's pizza")) - self.assertEqual(r"luigi\'s\ pizza", shell_escape("luigi's pizza")) - self.assertEqual(r"\$lol/foo\\xyz\|\>\<\]\[", - shell_escape(r"$lol/foo\xyz|><][")) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_history.py b/test/tc_history.py deleted file mode 100644 index 02a8bb9f..00000000 --- a/test/tc_history.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from ranger.container import History -from unittest import TestCase, main -import unittest - -class Test(TestCase): - def test_history(self): - hist = History(3) - for i in range(6): - hist.add(i) - self.assertEqual([3,4,5], list(hist)) - - hist.back() - - self.assertEqual(4, hist.current()) - self.assertEqual([3,4], list(hist._left())) - - self.assertEqual(5, hist.top()) - - hist.back() - self.assertEqual(3, hist.current()) - self.assertEqual([3], list(hist._left())) - - # no change if current == bottom - self.assertEqual(hist.current(), hist.bottom()) - last = hist.current() - hist.back() - self.assertEqual(hist.current(), last) - - self.assertEqual(5, hist.top()) - - hist.forward() - hist.forward() - self.assertEqual(5, hist.current()) - self.assertEqual([3,4,5], list(hist._left())) - - - self.assertEqual(3, hist.bottom()) - hist.add(6) - self.assertEqual(4, hist.bottom()) - self.assertEqual([4,5,6], list(hist._left())) - - hist.back() - hist.fast_forward() - self.assertEqual([4,5,6], list(hist._left())) - hist.back() - hist.back() - hist.fast_forward() - self.assertEqual([4,5,6], list(hist._left())) - hist.back() - hist.back() - hist.back() - hist.fast_forward() - self.assertEqual([4,5,6], list(hist._left())) - hist.back() - hist.back() - hist.back() - hist.back() - hist.fast_forward() - self.assertEqual([4,5,6], list(hist._left())) - -if __name__ == '__main__': main() diff --git a/test/tc_human_readable.py b/test/tc_human_readable.py deleted file mode 100644 index 493e6d3a..00000000 --- a/test/tc_human_readable.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -from ranger.ext.human_readable import human_readable as hr - -class HumanReadableTest(unittest.TestCase): - def test_basic(self): - self.assertEqual("0", hr(0)) - self.assertEqual("1 B", hr(1)) - self.assertEqual("1 K", hr(2 ** 10)) - self.assertEqual("1 M", hr(2 ** 20)) - self.assertEqual("1 G", hr(2 ** 30)) - self.assertEqual(">9000", hr(2 ** 100)) - - def test_big(self): - self.assertEqual("1023 G", hr(2 ** 30 * 1023)) - self.assertEqual("1024 G", hr(2 ** 40 - 1)) - self.assertEqual("1 T", hr(2 ** 40)) - - def test_small(self): - self.assertEqual("1000 B", hr(1000)) - self.assertEqual("1.66 M", hr(1.66 * 2 ** 20)) - self.assertEqual("1.46 K", hr(1500)) - self.assertEqual("1.5 K", hr(2 ** 10 + 2 ** 9)) - self.assertEqual("1.5 K", hr(2 ** 10 + 2 ** 9 - 1)) - - def test_no_exponent(self): - for i in range(2 ** 10, 2 ** 20, 512): - self.assertTrue('e' not in hr(i), "%d => %s" % (i, hr(i))) - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_keyapi.py b/test/tc_keyapi.py deleted file mode 100644 index 79d89fa5..00000000 --- a/test/tc_keyapi.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -from unittest import TestCase, main - -class Test(TestCase): - def test_wrapper(self): - from ranger.api.keys import Wrapper - - class dummyfm(object): - def move(self, relative): - return "I move down by {0}".format(relative) - - class commandarg(object): - def __init__(self): - self.fm = dummyfm() - self.n = None - self.direction = None - - arg = commandarg() - - do = Wrapper('fm') - command = do.move(relative=4) - - self.assertEqual(command(arg), 'I move down by 4') - -if __name__ == '__main__': main() diff --git a/test/tc_loader.py b/test/tc_loader.py deleted file mode 100644 index a679a629..00000000 --- a/test/tc_loader.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -import os -from os.path import realpath, join, dirname - -from testlib import Fake -from ranger.core.shared import FileManagerAware, SettingsAware -from ranger.core.loader import Loader -from ranger.fsobject import Directory, File -from ranger.ext.openstruct import OpenStruct - -TESTDIR = realpath(join(dirname(__file__), 'testdir')) -#TESTDIR = "/usr/sbin" - -class Test1(unittest.TestCase): - def test_loader(self): - loader = Loader() - fm = OpenStruct(loader=loader) - SettingsAware.settings = Fake() - FileManagerAware.fm = fm - - # initially, the loader has nothing to do - self.assertFalse(loader.has_work()) - - dir = Directory(TESTDIR) - self.assertEqual(None, dir.files) - self.assertFalse(loader.has_work()) - - # Calling load_content() will enqueue the loading operation. - # dir is not loaded yet, but the loader has work - dir.load_content(schedule=True) - self.assertEqual(None, dir.files) - self.assertTrue(loader.has_work()) - - iterations = 0 - while loader.has_work(): - iterations += 1 - loader.work() - #print(iterations) - self.assertNotEqual(None, dir.files) - self.assertFalse(loader.has_work()) -# -# def test_get_overhead_of_loader(self): -# N = 5 -# tloader = benchmark_load(N) -# traw = benchmark_raw_load(N) -# #traw1k = 250.0 -# #traw = traw1k * N / 1000.0 -# #print("Loader: {0}s".format(tloader)) -# #print("Raw: {0}s".format(traw)) -# self.assertTrue(tloader > traw) -# overhead = tloader * 100 / traw - 100 -# self.assertTrue(overhead < 2, "overhead of loader too high: {0}" \ -# .format(overhead)) -# #print("Overhead: {0:.5}%".format(overhead)) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py deleted file mode 100644 index c9597201..00000000 --- a/test/tc_newkeys.py +++ /dev/null @@ -1,620 +0,0 @@ -# coding=utf-8 -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] -sys.path[1:1] = ['..'] - -from unittest import TestCase, main - -from testlib import TODO -from ranger.ext.tree import Tree -from ranger.container.keymap import * -from ranger.container.keybuffer import KeyBuffer -from ranger.ext.keybinding_parser import parse_keybinding - -def simulate_press(self, string): - for char in parse_keybinding(string): - self.add(char) - if self.done: - return self.command - if self.failure: - break - return self.command - -class PressTestCase(TestCase): - """Some useful methods for the actual test""" - def _mkpress(self, keybuffer, _=0): - def press(keys): - keybuffer.clear() - match = simulate_press(keybuffer, keys) - self.assertFalse(keybuffer.failure, - "parsing keys '"+keys+"' did fail!") - self.assertTrue(keybuffer.done, - "parsing keys '"+keys+"' did not complete!") - arg = CommandArgs(None, None, keybuffer) - self.assert_(match.function, "No function found! " + \ - str(match.__dict__)) - return match.function(arg) - return press - - def assertPressFails(self, kb, keys): - kb.clear() - simulate_press(kb, keys) - self.assertTrue(kb.failure, "Keypress did not fail as expected") - kb.clear() - - def assertPressIncomplete(self, kb, keys): - kb.clear() - simulate_press(kb, keys) - self.assertFalse(kb.failure, "Keypress failed, expected incomplete") - self.assertFalse(kb.done, "Keypress done which was unexpected") - kb.clear() - -class Test(PressTestCase): - """The test cases""" - def test_passive_action(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - def n(value): - """return n or value""" - def fnc(arg=None): - if arg is None or arg.n is None: - return value - return arg.n - return fnc - - km.map('ppp', n(5)) - km.map('pp', n(8)) - km.map('pp', n(2)) - directions.map('j', dir=Direction(down=1)) - - press = self._mkpress(kb, km) - self.assertEqual(5, press('ppp')) - self.assertEqual(3, press('3ppp')) - - self.assertEqual(2, press('ppj')) - - kb.clear() - match = simulate_press(kb, 'pp') - args = CommandArgs(0, 0, kb) - self.assert_(match) - self.assert_(match.function) - self.assertEqual(8, match.function(args)) - - def test_translate_keys(self): - def test(string, *args): - if not args: - args = (string, ) - self.assertEqual(ordtuple(*args), tuple(parse_keybinding(string))) - - def ordtuple(*args): - lst = [] - for arg in args: - if isinstance(arg, str): - lst.extend(ord(c) for c in arg) - else: - lst.append(arg) - return tuple(lst) - - # 1 argument means: assume nothing is translated. - test('k') - test('kj') - test('k', 'k', DIRKEY) - test('kz', 'k', ANYKEY, 'z', ANYKEY) - test('kz', 'k', ANYKEY, 'z', DIRKEY) - test('', "\n") - test('', "\t\t\n") - test('<') - test('>') - test('', 1) - test('', 2) - for i in range(1, 26): - test('', i) - test('', 27, ord('x')) - test('', 27, ord('o')) - test('k') - test('k') - test('k') - test('knz>') - test('>nz>') - - def test_alias(self): - def add_dirs(arg): - return sum(dir.down() for dir in arg.directions) - def return5(_): - return 5 - - directions = KeyMap() - directions.map('j', dir=Direction(down=1)) - directions.map('k', dir=Direction(down=-1)) - directions.map('', alias='j') - directions.map('@', alias='') - - base = KeyMap() - base.map('a', add_dirs) - base.map('b', add_dirs) - base.map('xx', add_dirs) - base.map('f', return5) - base.map('yy', alias='y') - base.map('!', alias='!') - - other = KeyMap() - other.map('bb', alias='xx') - other.map('c', add_dirs) - other.map('g', alias='f') - - km = base.merge(other, copy=True) - kb = KeyBuffer(km, directions) - - press = self._mkpress(kb, km) - - self.assertEqual(1, press('aj')) - self.assertEqual(2, press('bjbj')) - self.assertEqual(1, press('cj')) - self.assertEqual(1, press('c')) - - self.assertEqual(5, press('f')) - self.assertEqual(5, press('g')) - self.assertEqual(press('c'), press('c@')) - self.assertEqual(press('c'), press('c@')) - self.assertEqual(press('c'), press('c@')) - - for n in range(1, 10): - self.assertPressIncomplete(kb, 'y' * n) - - for n in range(1, 5): - self.assertPressFails(kb, '!' * n) - - def test_tree(self): - t = Tree() - t.set('abcd', "Yes") - self.assertEqual("Yes", t.traverse('abcd')) - self.assertRaises(KeyError, t.traverse, 'abcde') - self.assertRaises(KeyError, t.traverse, 'xyz') - self.assert_(isinstance(t.traverse('abc'), Tree)) - - t2 = Tree() - self.assertRaises(KeyError, t2.set, 'axy', "Lol", force=False) - t2.set('axx', 'ololol') - t2.set('axyy', "Lol") - self.assertEqual("Yes", t.traverse('abcd')) - self.assertRaises(KeyError, t2.traverse, 'abcd') - self.assertEqual("Lol", t2.traverse('axyy')) - self.assertEqual("ololol", t2.traverse('axx')) - - t2.unset('axyy') - self.assertEqual("ololol", t2.traverse('axx')) - self.assertRaises(KeyError, t2.traverse, 'axyy') - self.assertRaises(KeyError, t2.traverse, 'axy') - - t2.unset('a') - self.assertRaises(KeyError, t2.traverse, 'abcd') - self.assertRaises(KeyError, t2.traverse, 'a') - self.assert_(t2.empty()) - - def test_merge_trees(self): - def makeTreeA(): - t = Tree() - t.set('aaaX', 1) - t.set('aaaY', 2) - t.set('aaaZ', 3) - t.set('bbbA', 11) - t.set('bbbB', 12) - t.set('bbbC', 13) - t.set('bbbD', 14) - t.set('bP', 21) - t.set('bQ', 22) - return t - - def makeTreeB(): - u = Tree() - u.set('aaaX', 0) - u.set('bbbC', 'Yes') - u.set('bbbD', None) - u.set('bbbE', 15) - u.set('bbbF', 16) - u.set('bQ', 22) - u.set('bR', 23) - u.set('ffff', 1337) - return u - - # test 1 - t = Tree('a') - u = Tree('b') - merged = t.merge(u, copy=True) - self.assertEqual('b', merged._tree) - - # test 2 - t = Tree('a') - u = makeTreeA() - merged = t.merge(u, copy=True) - self.assertEqual(u._tree, merged._tree) - - # test 3 - t = makeTreeA() - u = makeTreeB() - v = t.merge(u, copy=True) - - self.assertEqual(0, v['aaaX']) - self.assertEqual(2, v['aaaY']) - self.assertEqual(3, v['aaaZ']) - self.assertEqual(11, v['bbbA']) - self.assertEqual('Yes', v['bbbC']) - self.assertEqual(None, v['bbbD']) - self.assertEqual(15, v['bbbE']) - self.assertEqual(16, v['bbbF']) - self.assertRaises(KeyError, t.__getitem__, 'bbbG') - self.assertEqual(21, v['bP']) - self.assertEqual(22, v['bQ']) - self.assertEqual(23, v['bR']) - self.assertEqual(1337, v['ffff']) - - # merge shouldn't be destructive - self.assertEqual(makeTreeA()._tree, t._tree) - self.assertEqual(makeTreeB()._tree, u._tree) - - v['fff'].replace('Lolz') - self.assertEqual('Lolz', v['fff']) - - v['aaa'].replace('Very bad') - v.plow('qqqqqqq').replace('eww.') - - self.assertEqual(makeTreeA()._tree, t._tree) - self.assertEqual(makeTreeB()._tree, u._tree) - - def test_add(self): - c = KeyMap() - c.map('aa', 'b', lambda *_: 'lolz') - self.assert_(c['aa'].function(), 'lolz') - @c.map('a', 'c') - def test(): - return 5 - self.assert_(c['b'].function(), 'lolz') - self.assert_(c['c'].function(), 5) - self.assert_(c['a'].function(), 5) - - def test_quantifier(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - def n(value): - """return n or value""" - def fnc(arg=None): - if arg is None or arg.n is None: - return value - return arg.n - return fnc - km.map('p', n(5)) - press = self._mkpress(kb, km) - self.assertEqual(5, press('p')) - self.assertEqual(3, press('3p')) - self.assertEqual(6223, press('6223p')) - - def test_direction(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - directions.map('j', dir=Direction(down=1)) - directions.map('k', dir=Direction(down=-1)) - def nd(arg): - """ n * direction """ - n = arg.n is None and 1 or arg.n - dir = arg.direction is None and Direction(down=1) \ - or arg.direction - return n * dir.down() - km.map('d', nd) - km.map('dd', func=nd) - - press = self._mkpress(kb, km) - - self.assertPressIncomplete(kb, 'd') - self.assertEqual( 1, press('dj')) - self.assertEqual( 3, press('3ddj')) - self.assertEqual( 15, press('3d5j')) - self.assertEqual(-15, press('3d5k')) - # supporting this kind of key combination would be too confusing: - # self.assertEqual( 15, press('3d5d')) - self.assertEqual( 3, press('3dd')) - self.assertEqual( 33, press('33dd')) - self.assertEqual( 1, press('dd')) - - km.map('x', nd) - km.map('xxxx', func=nd) - - self.assertEqual(1, press('xxxxj')) - self.assertEqual(1, press('xxxxjsomeinvalitchars')) - - # these combinations should break: - self.assertPressFails(kb, 'xxxj') - self.assertPressFails(kb, 'xxj') - self.assertPressFails(kb, 'xxkldfjalksdjklsfsldkj') - self.assertPressFails(kb, 'xyj') - self.assertPressIncomplete(kb, 'x') # direction missing - - def test_any_key(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - directions.map('j', dir=Direction(down=1)) - directions.map('k', dir=Direction(down=-1)) - - directions.map('g', dir=Direction(down=-1)) - - def cat(arg): - n = arg.n is None and 1 or arg.n - return ''.join(chr(c) for c in arg.matches) * n - - km.map('return', cat) - km.map('cat4', cat) - km.map('foo', cat) - - press = self._mkpress(kb, km) - - self.assertEqual('x', press('returnx')) - self.assertEqual('abcd', press('cat4abcd')) - self.assertEqual('abcdabcd', press('2cat4abcd')) - self.assertEqual('55555', press('5return5')) - - self.assertEqual('x', press('foojx')) - self.assertPressFails(kb, 'fooggx') # ANYKEY forbidden in DIRECTION - - km.map('', lambda _: Ellipsis) - self.assertEqual('x', press('returnx')) - self.assertEqual('abcd', press('cat4abcd')) - self.assertEqual(Ellipsis, press('2cat4abcd')) - self.assertEqual(Ellipsis, press('5return5')) - self.assertEqual(Ellipsis, press('g')) - self.assertEqual(Ellipsis, press('ß')) - self.assertEqual(Ellipsis, press('ア')) - self.assertEqual(Ellipsis, press('9')) - - def test_multiple_directions(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - directions.map('j', dir=Direction(down=1)) - directions.map('k', dir=Direction(down=-1)) - - def add_dirs(arg): - return sum(dir.down() for dir in arg.directions) - - km.map('xy', add_dirs) - km.map('four', add_dirs) - - press = self._mkpress(kb, km) - - self.assertEqual(2, press('xjyj')) - self.assertEqual(0, press('fourjkkj')) - self.assertEqual(2, press('four2j4k2j2j')) - self.assertEqual(10, press('four1j2j3j4j')) - self.assertEqual(10, press('four1j2j3j4jafslkdfjkldj')) - - def test_corruptions(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - press = self._mkpress(kb, km) - directions.map('j', dir=Direction(down=1)) - directions.map('k', dir=Direction(down=-1)) - km.map('xxx', lambda _: 1) - - self.assertEqual(1, press('xxx')) - - # corrupt the tree - tup = tuple(parse_keybinding('xxx')) - x = ord('x') - km._tree[x][x][x] = "Boo" - - self.assertPressFails(kb, 'xxy') - self.assertPressFails(kb, 'xzy') - self.assertPressIncomplete(kb, 'xx') - self.assertPressIncomplete(kb, 'x') - if not sys.flags.optimize: # asserts are ignored with python -O - self.assertRaises(AssertionError, simulate_press, kb, 'xxx') - kb.clear() - - def test_directions_as_functions(self): - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - press = self._mkpress(kb, km) - - def move(arg): - return arg.direction.down() - - directions.map('j', dir=Direction(down=1)) - directions.map('s', alias='j') - directions.map('k', dir=Direction(down=-1)) - km.map('', func=move) - - self.assertEqual(1, press('j')) - self.assertEqual(1, press('j')) - self.assertEqual(1, press('j')) - self.assertEqual(1, press('j')) - self.assertEqual(1, press('j')) - self.assertEqual(1, press('s')) - self.assertEqual(1, press('s')) - self.assertEqual(1, press('s')) - self.assertEqual(1, press('s')) - self.assertEqual(1, press('s')) - self.assertEqual(-1, press('k')) - self.assertEqual(-1, press('k')) - self.assertEqual(-1, press('k')) - - km.map('k', func=lambda _: 'love') - - self.assertEqual(1, press('j')) - self.assertEqual('love', press('k')) - - self.assertEqual(1, press('40j')) - self.assertEqual(40, kb.quant) - - km.map('', func=move) - - self.assertEqual(1, press('40jkhl')) - self.assertEqual(40, kb.quant) - - def test_tree_deep_copy(self): - t = Tree() - s = t.plow('abcd') - s.replace('X') - u = t.copy() - self.assertEqual(t._tree, u._tree) - s = t.traverse('abc') - s.replace('Y') - self.assertNotEqual(t._tree, u._tree) - - def test_keymanager(self): - def func(arg): - return 5 - def getdown(arg): - return arg.direction.down() - - buffer = KeyBuffer(None, None) - press = self._mkpress(buffer) - keymanager = KeyManager(buffer, ['foo', 'bar']) - - map = keymanager.get_context('foo') - map('a', func) - map('b', func) - map = keymanager.get_context('bar') - map('c', func) - map('', getdown) - - keymanager.dir('foo', 'j', down=1) - keymanager.dir('bar', 'j', down=1) - - keymanager.use_context('foo') - self.assertEqual(5, press('a')) - self.assertEqual(5, press('b')) - self.assertPressFails(buffer, 'c') - - keymanager.use_context('bar') - self.assertPressFails(buffer, 'a') - self.assertPressFails(buffer, 'b') - self.assertEqual(5, press('c')) - self.assertEqual(1, press('j')) - keymanager.use_context('foo') - keymanager.use_context('foo') - keymanager.use_context('foo') - keymanager.use_context('bar') - keymanager.use_context('foo') - keymanager.use_context('bar') - keymanager.use_context('bar') - self.assertEqual(1, press('j')) - - def test_alias_to_direction(self): - def func(arg): - return arg.direction.down() - - km = KeyMapWithDirections() - kb = KeyBuffer(km, km.directions) - press = self._mkpress(kb) - - km.map('', func) - km.map('d', func) - km.dir('j', down=42) - km.dir('k', alias='j') - self.assertEqual(42, press('j')) - - km.dir('o', alias='j') - km.dir('ick', alias='j') - self.assertEqual(42, press('o')) - self.assertEqual(42, press('dj')) - self.assertEqual(42, press('dk')) - self.assertEqual(42, press('do')) - self.assertEqual(42, press('dick')) - self.assertPressFails(kb, 'dioo') - - def test_both_directory_and_any_key(self): - def func(arg): - return arg.direction.down() - def func2(arg): - return "yay" - - km = KeyMap() - directions = KeyMap() - kb = KeyBuffer(km, directions) - press = self._mkpress(kb) - - km.map('abc', func) - directions.map('j', dir=Direction(down=42)) - self.assertEqual(42, press('abcj')) - - km.unmap('abc') - - km.map('abc', func2) - self.assertEqual("yay", press('abcd')) - - km.map('abc', func) - - km.map('abc', func2) - self.assertEqual("yay", press('abcd')) - - def test_map_collision(self): - def add_dirs(arg): - return sum(dir.down() for dir in arg.directions) - def return5(_): - return 5 - - - directions = KeyMap() - directions.map('gg', dir=Direction(down=1)) - - - km = KeyMap() - km.map('gh', return5) - km.map('agh', return5) - km.map('a', add_dirs) - - kb = KeyBuffer(km, directions) - press = self._mkpress(kb, km) - - self.assertEqual(5, press('gh')) - self.assertEqual(5, press('agh')) -# self.assertPressFails(kb, 'agh') - - @TODO - def test_map_collision2(self): - directions = KeyMap() - directions.map('gg', dir=Direction(down=1)) - km = KeyMap() - km.map('agh', lambda _: 1) - km.map('a', lambda _: 2) - kb = KeyBuffer(km, directions) - press = self._mkpress(kb, km) - self.assertEqual(1, press('agh')) - self.assertEqual(2, press('agg')) - - def test_keymap_with_dir(self): - def func(arg): - return arg.direction.down() - - km = KeyMapWithDirections() - kb = KeyBuffer(km, km.directions) - - press = self._mkpress(kb) - - km.map('abc', func) - km.dir('j', down=42) - self.assertEqual(42, press('abcj')) - -if __name__ == '__main__': main() diff --git a/test/tc_relative_symlink.py b/test/tc_relative_symlink.py deleted file mode 100644 index a202513d..00000000 --- a/test/tc_relative_symlink.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -from ranger.ext.relative_symlink import * -rel = get_relative_source_file - -class Test(unittest.TestCase): - def test_foo(self): - self.assertEqual('../foo', rel('/foo', '/x/bar')) - self.assertEqual('../../foo', rel('/foo', '/x/y/bar')) - self.assertEqual('../../a/b/foo', rel('/a/b/foo', '/x/y/bar')) - self.assertEqual('../../x/b/foo', rel('/x/b/foo', '/x/y/bar', - common_base='/')) - self.assertEqual('../b/foo', rel('/x/b/foo', '/x/y/bar')) - self.assertEqual('../b/foo', rel('/x/b/foo', '/x/y/bar')) - - def test_get_common_base(self): - self.assertEqual('/', get_common_base('', '')) - self.assertEqual('/', get_common_base('', '/')) - self.assertEqual('/', get_common_base('/', '')) - self.assertEqual('/', get_common_base('/', '/')) - self.assertEqual('/', get_common_base('/bla/bar/x', '/foo/bar/a')) - self.assertEqual('/foo/bar/', get_common_base('/foo/bar/x', '/foo/bar/a')) - self.assertEqual('/foo/', get_common_base('/foo/bar/x', '/foo/baz/a')) - self.assertEqual('/foo/', get_common_base('/foo/bar/x', '/foo/baz/a')) - self.assertEqual('/', get_common_base('//foo/bar/x', '/foo/baz/a')) - -if __name__ == '__main__': unittest.main() diff --git a/test/tc_signal.py b/test/tc_signal.py deleted file mode 100644 index 6547bbc3..00000000 --- a/test/tc_signal.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -import gc -from ranger.ext.signals import * - -class TestSignal(unittest.TestCase): - def setUp(self): - self.sd = SignalDispatcher() - - def test_signal_register_emit(self): - sd = self.sd - def poo(sig): - self.assert_('works' in sig) - self.assertEqual('yes', sig.works) - handler = sd.signal_bind('x', poo) - - sd.signal_emit('x', works='yes') - sd.signal_unbind(handler) - sd.signal_emit('x') - - def test_signal_order(self): - sd = self.sd - lst = [] - def addn(n): - return lambda _: lst.append(n) - - sd.signal_bind('x', addn(6)) - sd.signal_bind('x', addn(3), priority=1) - sd.signal_bind('x', addn(2), priority=1) - sd.signal_bind('x', addn(9), priority=0) - sd.signal_bind('x', addn(1337), priority=0.7) - sd.signal_emit('x') - - self.assert_(lst.index(3) < lst.index(6)) - self.assert_(lst.index(2) < lst.index(6)) - self.assert_(lst.index(6) < lst.index(9)) - self.assert_(lst.index(1337) < lst.index(6)) - self.assert_(lst.index(1337) < lst.index(9)) - self.assert_(lst.index(1337) > lst.index(2)) - - def test_modifying_arguments(self): - sd = self.sd - lst = [] - def modify(s): - s.number = 5 - def set_number(s): - lst.append(s.number) - def stopit(s): - s.stop() - - sd.signal_bind('setnumber', set_number) - sd.signal_emit('setnumber', number=100) - self.assertEqual(100, lst[-1]) - - sd.signal_bind('setnumber', modify, priority=1) - sd.signal_emit('setnumber', number=100) - self.assertEqual(5, lst[-1]) - - lst.append(None) - sd.signal_bind('setnumber', stopit, priority=1) - sd.signal_emit('setnumber', number=100) - self.assertEqual(None, lst[-1]) - - def test_weak_refs(self): - sd = self.sd - is_deleted = [False] - - class Foo(object): - def __init__(self): - self.alphabet = ['a'] - def calc(self, signal): - self.alphabet.append(chr(ord(self.alphabet[-1]) + 1)) - def __del__(self): - is_deleted[0] = True - - foo = Foo() - alphabet = foo.alphabet - calc = foo.calc - - del foo - self.assertEqual('a', ''.join(alphabet)) - sd.signal_bind('mysignal', calc, weak=True) - sd.signal_emit('mysignal') - self.assertEqual('ab', ''.join(alphabet)) - self.assertFalse(is_deleted[0]) - - del calc - self.assertTrue(is_deleted[0]) - - def test_weak_refs_dead_on_arrival(self): - sd = self.sd - is_deleted = [False] - - class Foo(object): - def __init__(self): - self.alphabet = ['a'] - def calc(self, signal): - self.alphabet.append(chr(ord(self.alphabet[-1]) + 1)) - def __del__(self): - is_deleted[0] = True - - foo = Foo() - alphabet = foo.alphabet - - self.assertEqual('a', ''.join(alphabet)) - sd.signal_bind('mysignal', foo.calc, weak=True) - - sd.signal_emit('mysignal') - self.assertEqual('ab', ''.join(alphabet)) - self.assertFalse(is_deleted[0]) - - del foo - - sd.signal_emit('mysignal') - self.assertEqual('ab', ''.join(alphabet)) - self.assertTrue(is_deleted[0]) - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_ui.py b/test/tc_ui.py deleted file mode 100644 index fa2bdcac..00000000 --- a/test/tc_ui.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] - -import unittest -import curses - -from ranger.gui import ui - -from testlib import Fake, OK, raise_ok - -ui.curses = Fake() - -class Test(unittest.TestCase): - def setUp(self): - - self.fm = Fake() - self.ui = ui.UI(env=Fake(), fm=self.fm) - - def fakesetup(): - self.ui.widget = Fake() - self.ui.add_child(self.ui.widget) - self.ui.setup = fakesetup - - self.ui.initialize() - - def tearDown(self): - self.ui.destroy() - - def test_passing(self): - # Test whether certain method calls are passed to widgets - widget = self.ui.widget - - widget.draw = raise_ok - self.assertRaises(OK, self.ui.draw) - widget.__clear__() - - widget.finalize = raise_ok - self.assertRaises(OK, self.ui.finalize) - widget.__clear__() - - widget.press = raise_ok - random_key = 123 - self.assertRaises(OK, self.ui.handle_key, random_key) - widget.__clear__() - - widget.destroy = raise_ok - self.assertRaises(OK, self.ui.destroy) - widget.__clear__() - -if __name__ == '__main__': - unittest.main() diff --git a/test/tc_utfwidth.py b/test/tc_utfwidth.py deleted file mode 100644 index 0288c17b..00000000 --- a/test/tc_utfwidth.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- encoding: utf8 -*- -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License - -import os.path -import sys -rangerpath = os.path.join(os.path.dirname(__file__), '..') -if sys.path[1] != rangerpath: - sys.path[1:1] = [rangerpath] -sys.path[1:1] = ['..'] - -from unittest import TestCase, main -from ranger.ext.utfwidth import * - -a_ascii = "a" # width = 1, bytes = 1 -a_umlaut = "ä" # width = 1, bytes = 2 -a_katakana = "ア" # width = 2, bytes = 3 -# need one with width = 1 & bytes = 3 - -class Test(TestCase): - def test_utf_byte_length(self): - self.assertEqual(1, utf_byte_length(a_ascii)) - self.assertEqual(2, utf_byte_length(a_umlaut)) - self.assertEqual(3, utf_byte_length(a_katakana)) - - def test_uwid(self): - self.assertEqual(1, uwid(a_ascii)) - self.assertEqual(1, uwid(a_umlaut)) - self.assertEqual(2, uwid(a_katakana)) - self.assertEqual(3, uwid(a_katakana + a_umlaut)) - self.assertEqual(4, uwid("asdf")) - self.assertEqual(5, uwid("löööl")) - self.assertEqual(6, uwid("バババ")) - -if __name__ == '__main__': main() diff --git a/test/testdir/largefile.txt b/test/testdir/largefile.txt deleted file mode 100644 index 0eb8c64f..00000000 --- a/test/testdir/largefile.txt +++ /dev/null @@ -1 +0,0 @@ -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/test/testdir/symlink b/test/testdir/symlink deleted file mode 120000 index 5cbc1596..00000000 --- a/test/testdir/symlink +++ /dev/null @@ -1 +0,0 @@ -textfile.txt \ No newline at end of file diff --git a/test/testdir/textfile.txt b/test/testdir/textfile.txt deleted file mode 100644 index 45a23497..00000000 --- a/test/testdir/textfile.txt +++ /dev/null @@ -1,4 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. -Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. -Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/test/testdir/zerobytes b/test/testdir/zerobytes deleted file mode 100644 index e69de29b..00000000 diff --git a/test/testlib.py b/test/testlib.py deleted file mode 100644 index 29dd9e07..00000000 --- a/test/testlib.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -def TODO(fnc): - def result(*arg, **kw): - try: - fnc(*arg, **kw) - except: - pass # failure expected - return result - -class Fake(object): - def __getattr__(self, attrname): - val = Fake() - self.__dict__[attrname] = val - return val - - def __call__(self, *_, **__): - return Fake() - - def __clear__(self): - self.__dict__.clear() - - def __iter__(self): - return iter(()) - -class OK(Exception): - pass - -def raise_ok(*_, **__): - raise OK() -- cgit 1.4.1-2-gfad0