summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-01-20 12:07:53 +0100
committernfnty <git@nfnty.se>2017-01-20 12:07:53 +0100
commit1c90e610de6591e8052a1056c775219b5e767002 (patch)
tree69b56f67dee1d6dfcea869de897846baaded3fa6 /tests
parente26d163debc9f55a89a27f94a43771526d2ff0b7 (diff)
parent03ee065e35c6a8f0e0dc1e66d8f4c3e83c51f315 (diff)
downloadranger-1c90e610de6591e8052a1056c775219b5e767002.tar.gz
Merge branch 'lint'
Diffstat (limited to 'tests')
-rw-r--r--tests/ranger/container/test_bookmarks.py3
-rw-r--r--tests/ranger/container/test_container.py98
-rw-r--r--tests/ranger/container/test_fsobject.py13
3 files changed, 60 insertions, 54 deletions
diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py
index a2cd446f..d5bafc6c 100644
--- a/tests/ranger/container/test_bookmarks.py
+++ b/tests/ranger/container/test_bookmarks.py
@@ -1,5 +1,8 @@
+from __future__ import (absolute_import, print_function)
+
 import os
 import time
+
 import pytest
 
 from ranger.container.bookmarks import Bookmarks
diff --git a/tests/ranger/container/test_container.py b/tests/ranger/container/test_container.py
index 2b823912..2af96592 100644
--- a/tests/ranger/container/test_container.py
+++ b/tests/ranger/container/test_container.py
@@ -1,3 +1,5 @@
+from __future__ import (absolute_import, print_function)
+
 from ranger.container import history
 
 
@@ -10,92 +12,92 @@ def testhistorybasic():
     # item added to it. It has a `current` index that serves as a cursor.
 
     # A history has a limited size, check that only `maxlen` items are stored
-    h = history.History(maxlen=10)
+    hist = history.History(maxlen=10)
     for entry in HISTORY_TEST_ENTRIES:
-        h.add(entry)
+        hist.add(entry)
 
     # 10 items are stored
-    assert len(h) == 10
-    assert h.current() == "19"
-    assert h.top() == "19"
-    assert h.bottom() == "10"
+    assert len(hist) == 10
+    assert hist.current() == "19"
+    assert hist.top() == "19"
+    assert hist.bottom() == "10"
 
     # going back in time affects only changes current item
-    h.back()
-    assert len(h) == 10
-    assert h.current() == "18"
-    assert h.top() == "19"
-    assert h.bottom() == "10"
+    hist.back()
+    assert len(hist) == 10
+    assert hist.current() == "18"
+    assert hist.top() == "19"
+    assert hist.bottom() == "10"
 
     # __iter__ is actually an interator and we can iterate through the list
-    it = iter(h)
-    assert iter(it) == it
-    assert list(it) == HISTORY_TEST_ENTRIES[10:]
+    iterator = iter(hist)
+    assert iter(iterator) == iterator
+    assert list(iterator) == HISTORY_TEST_ENTRIES[10:]
 
     # search allows to go back in time as long as a pattern matches and we don't
     # go over a step limit
-    assert h.search("45", -9) == "18"
-    assert h.search("1", -5) == "13"
+    assert hist.search("45", -9) == "18"
+    assert hist.search("1", -5) == "13"
 
     # fast forward selects the last item
-    h.fast_forward()
-    assert h.current() == "19"
+    hist.fast_forward()
+    assert hist.current() == "19"
 
     # back followed by forward is a noop
-    h.back()
-    h.forward()
-    assert h.current() == "19"
+    hist.back()
+    hist.forward()
+    assert hist.current() == "19"
 
     # move can be expressed as multiple calls to back and forward
-    h.move(-3)
-    h.forward()
-    h.forward()
-    h.forward()
-    assert h.current() == "19"
+    hist.move(-3)
+    hist.forward()
+    hist.forward()
+    hist.forward()
+    assert hist.current() == "19"
 
     # back, forward, move play well with boundaries
     for _ in range(30):
-        h.back()
+        hist.back()
 
     for _ in range(30):
-        h.forward()
+        hist.forward()
 
     for _ in range(30):
-        h.move(-2)
+        hist.move(-2)
 
     for _ in range(30):
-        h.move(2)
-    assert h.current() == "19"
+        hist.move(2)
+    assert hist.current() == "19"
 
     # we can create an history from another history
-    h = history.History(maxlen=10)
+    hist = history.History(maxlen=10)
     for entry in HISTORY_TEST_ENTRIES:
-        h.add(entry)
+        hist.add(entry)
     # XXX maxlen should not be used to refer to something that isn't a length
-    otherh = history.History(maxlen=h)
-    assert(list(h) == list(otherh))
+    otherh = history.History(maxlen=hist)
+    assert list(hist) == list(otherh)
 
     # Rebase replaces the past of the history with that of another
-    otherh = history.History(maxlen=h)
-    old_current_item = h.current()
+    otherh = history.History(maxlen=hist)
+    old_current_item = hist.current()
     for entry in OTHER_TEST_ENTRIES:
         otherh.add(entry)
     assert list(otherh)[-3:] == ["42", "43", "44"]
-    h.rebase(otherh)
-    assert h.current() == old_current_item
-    assert list(h)[-3:] == ['43', '44', old_current_item]
+    hist.rebase(otherh)
+    assert hist.current() == old_current_item
+    assert list(hist)[-3:] == ['43', '44', old_current_item]
 
     # modify, modifies the top of the stack
-    h.modify("23")
-    assert h.current() == "23"
+    hist.modify("23")
+    assert hist.current() == "23"
 
 
 def testhistoryunique():
     # Check that unique history refuses to store duplicated entries
-    h = history.History(maxlen=10, unique=True)
+    hist = history.History(maxlen=10, unique=True)
     for entry in HISTORY_TEST_ENTRIES:
-        h.add(entry)
-    assert h.current() == "19"
-    h.add("17")
-    assert list(h).count("17") == 1
-    assert h.current() == "17"
+        hist.add(entry)
+    assert hist.current() == "19"
+    hist.add("17")
+    assert list(hist).count("17") == 1
+    assert hist.current() == "17"
diff --git a/tests/ranger/container/test_fsobject.py b/tests/ranger/container/test_fsobject.py
index 73d2024a..8fe385c0 100644
--- a/tests/ranger/container/test_fsobject.py
+++ b/tests/ranger/container/test_fsobject.py
@@ -1,10 +1,11 @@
-import pytest
+from __future__ import (absolute_import, print_function)
+
 import operator
 
 from ranger.container.fsobject import FileSystemObject
 
 
-class MockFM(object):
+class MockFM(object):  # pylint: disable=too-few-public-methods
     """Used to fulfill the dependency by FileSystemObject."""
 
     default_linemodes = []
@@ -22,13 +23,13 @@ def test_basename_natural1():
     """Test filenames without extensions."""
     fsos = [create_filesystem_object(path)
             for path in ("hello", "hello1", "hello2")]
-    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
-    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))
+    assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural"))
+    assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower"))
 
 
 def test_basename_natural2():
     """Test filenames with extensions."""
     fsos = [create_filesystem_object(path)
             for path in ("hello", "hello.txt", "hello1.txt", "hello2.txt")]
-    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")))
-    assert(fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")))
+    assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural"))
+    assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower"))